Community
Participate
Working Groups
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729) Build Identifier: I20090611-1540 I'm using the construct "if (0 == 1)" to quickly enable/disable a code block. With 3.5, I get a "Dead Code" warning. I'd like an option to be able to keep the "Dead Code" warning for other code but it shouldn't warn for code like this: if (0 == 1) {...} and boolean enable = 0 == 1; if (enable) {...} PS: The advantage of "0 == 1" instead of commenting out the code: I don't have to fix the imports and/or local variables plus it's only a single character change in the VCS. Reproducible: Always
Please see bug 256463. Wouldn't the pattern supported in 3.5 work for you, too? (hint: use a constant)
Why not simply using "if (false) ..."? This won't be different from what you are writing.
(In reply to comment #2) > Why not simply using "if (false) ..."? > This won't be different from what you are writing. Yes, it would be: I would have to change more than a single character to flip the condition. Also the chance to encounter "if (0 == 1)" anywhere else in the code is pretty low which makes it a good candidate to guard debug code.
(In reply to comment #1) > Please see bug 256463. > > Wouldn't the pattern supported in 3.5 work for you, too? > (hint: use a constant) Thanks for the hint. It solves half of my problem (my second case above works with 3.5; I didn't actually try it before reporting the bug). So my bug report is now to allow "if (0 == 1)" in addition to what bug 256463 fixes. I'd rather track this with a new bug since bug 256463 is already closed.
The chances should not be higher to encounter "if (false)...".
(In reply to comment #5) > The chances should not be higher to encounter "if (false)...". Then do it. With "if (false)", you have to select "false" and replace it with "true". That's four to nine keys pressed. With "if (0 == 1)", it's two keys: Select or delete the "0", press "1". Which one is less work? :)
(In reply to comment #6) > (In reply to comment #5) > > The chances should not be higher to encounter "if (false)...". > > Then do it. With "if (false)", you have to select "false" and replace it with > "true". That's four to nine keys pressed. > > With "if (0 == 1)", it's two keys: Select or delete the "0", press "1". > > Which one is less work? :) If you're really concerned about a few keystrokes, why don't you let "!" be your friend? ;-) DEBUG = true; if (DEBUG) stmt; edit DEBUG = !true; Sound much easier than introducing more heuristics into the tool, no?
We cannot support everyone's dead code pattern. I believe we support the more comment ones. This is clearly low priority. Feel free to provide a patch.
Closing as WONTFIX. No plan to add this code pattern. if (DEBUG) or if (!DEBUG) is sufficient. We don't want to add special cases for each of the existing code patterns.
Verified for 3.6M3