Community
Participate
Working Groups
build i0504-0800 We have code which looks like the following: if (condition) methodCall(); else // unknown BOM... ignore it ; return result; We are getting a warning saying that the semi-colon in the "else" stmt is unncessary. But if we remove it, won't the "return" only be executed in the "else"?
In fact the whole else clause is useless. So it is true that the else statement is useless. Your code can be written like this: if (condition) methodCall(); return result; And it does the same thing.
Yep, I realize that. (and am going to address it) I was just worried about the case where I am going through and removing deprecations. Blindly removing the semi-colon is actually changing the code whereas the message sort of implies that its a no-op.
Just to clarify: the warning tells you that the statement in ELSE clause doesn't need to be nested in ELSE clause, it can be moved right behind. i.e. tt doesn't mean you should remove entirely the ELSE statement.
The warning is "Unncessary semicolon" and the code would be broken/changed if I removed it. (even worse is that removing the semi-colon is the option that Quick Fix offers me when I hit ctrl-1) If the warning message was "Empty ELSE statment...consider removing condition" then that would make sense. (and would allow Quick Fix to suggest the right correction)
Your original comment said you were actually seeing the proper warning. Can you clarify what is going on ?
Sorry, lack of sleep leads to confusing bugzilla reports. :-) After thinking about it, I'm not sure if the warning message is actually the one that should appear. I'm not sure what the resolution should be, but either the message should be changed from "Unnecessary semicolon" to "empty ELSE stmt" or the Quick-Fix should not remove the semi-colon as a solution to the problem because it changes the behaviour of the code.