Re: Detecting superfluous "else"

2018-07-21 Thread Didier Kryn
Le 19/07/2018 à 10:49, U.Mutlu a écrit : Hi, it makes me 'crazy' when I see such if-else constructs:   if (x)     return 7;   else     return 4; (Of course in this case one better would use the shorthand "return x ? 7 : 4;", but that's not the issue here) The 'else' is obviously superfluous/r

Re: Detecting superfluous "else"

2018-07-21 Thread Daniel Letai
On 19/07/2018 18:56, Eric Gallager wrote: On 7/19/18, U.Mutlu wrote: Hi, it makes me 'crazy' when I see such if-else constructs: if (x) return 7; else return 4; (Of course in this case one better would use the shorthand "return x ? 7 : 4;", but that's not the issue here)

Re: Detecting superfluous "else"

2018-07-19 Thread Eric Gallager
On 7/19/18, U.Mutlu wrote: > Hi, > it makes me 'crazy' when I see such if-else constructs: >if (x) > return 7; >else > return 4; > > (Of course in this case one better would use the shorthand "return x ? 7 : > 4;", but that's not the issue here) > > The 'else' is obviously superf

Re: Detecting superfluous "else"

2018-07-19 Thread Jonathan Wakely
On Thu, 19 Jul 2018 at 14:01, Paul Koning wrote: > Warnings are appropriate for code that is known to be a source of bugs, or > where there is a reasonable chance that the intent of the programmer doesn't > match what was actually written. That's not the case here. Agreed. This seems to be a pu

Re: Detecting superfluous "else"

2018-07-19 Thread Paul Koning
> On Jul 19, 2018, at 4:49 AM, U.Mutlu wrote: > > Hi, > it makes me 'crazy' when I see such if-else constructs: > if (x) >return 7; > else >return 4; > > (Of course in this case one better would use the shorthand "return x ? 7 : > 4;", but that's not the issue here) > > The 'else'

Detecting superfluous "else"

2018-07-19 Thread U.Mutlu
Hi, it makes me 'crazy' when I see such if-else constructs: if (x) return 7; else return 4; (Of course in this case one better would use the shorthand "return x ? 7 : 4;", but that's not the issue here) The 'else' is obviously superfluous/redundant, ie. unneeded at all: if (x)