invert if condition should not be the first

argghh! please keep the braindead programmers like me in mind!!

I too easily confirm "invert if condition" instead of "simplify if condition"


8 comments
Comment actions Permalink

Michael Damberger wrote:

I too easily confirm "invert if condition" instead of "simplify if condition"


The intention or the quick fix of the inspection? Perhaps you could
submit a JIRA request with a little bit of example code or a screen shot?

Bas

0
Comment actions Permalink

if (myvar == true) ...

was the original code, then the light bulb allows you to
- "invert if condition"
- "simplify boolean condition"

generally, it would be great to sort the "non-logic-breaking" intentions to the beginning of the list - you know, the kind of refactorings that do not alter the logical flow, or in other words, the "harmless" ones ;)

will make JIRA entry when I have more time...

0
Comment actions Permalink

I also think non-semantic intentions should be highlighted in some
special way, like with an asterisk or a differently colored lightbulb.
What would yo uthink of this?

Michael Damberger wrote:

if (myvar == true) ...

was the original code, then the light bulb allows you to
- "invert if condition"
- "simplify boolean condition"

generally, it would be great to sort the "non-logic-breaking" intentions to the beginning of the list - you know, the kind of refactorings that do not alter the logical flow, or in other words, the "harmless" ones ;)

will make JIRA entry when I have more time...

0
Comment actions Permalink

Both "invert if condition" and "simplify boolean condition" do not
change the semantics of the code actually.

Bas

Michael Damberger wrote:

if (myvar == true) ...

was the original code, then the light bulb allows you to - "invert if
condition" - "simplify boolean condition"

generally, it would be great to sort the "non-logic-breaking"
intentions to the beginning of the list - you know, the kind of
refactorings that do not alter the logical flow, or in other words,
the "harmless" ones ;)

will make JIRA entry when I have more time...

0
Comment actions Permalink

Michael Damberger wrote:

generally, it would be great to sort the "non-logic-breaking" intentions to the beginning of the list - you know, the kind of refactorings that do not alter the logical flow, or in other words, the "harmless" ones ;)


Strictly speaking, "invert if condition" is "harmless" as well as it doesn't
change the logic of your code. With so many new intentions around, it would
probably need a do-what-I-mean mind reading device that can select the intention
you want. And even then, people would complain that the intention order changes.
No wait, with a do-what-I-mean device we wouldn't need intention actions any
more at all, the correct code would just magically appear on the screen ;)

The best solution for this specific case would probably be to make the "invert
if condition" intention only available when the caret is placed on the "if"
keyword, but I think we already had that and it was requested to make it
available on the condition as well.

Sascha

0
Comment actions Permalink

Sascha Weinreuter wrote:

Michael Damberger wrote:

>> generally, it would be great to sort the "non-logic-breaking" intentions to the beginning of the list - you know, the kind of refactorings that do not alter the logical flow, or in other words, the "harmless" ones ;)


The best solution for this specific case would probably be to make the "invert
if condition" intention only available when the caret is placed on the "if"
keyword,


Agreed.

Bas

0
Comment actions Permalink

sorry - I should have looked what "invert if condition" really does.
it missed that it does not change semantics in fact!

0

Please sign in to leave a comment.