Idea for inspection/quickfix

I'm starting with this:

);
System.out.println("Color is " + color);]]>

Inlining my makeColor method gave me this code:

) {
   result = "Foo";
} else {
   result = "Fie";
}
String color = result;
System.out.println("Color is " + color);]]>

Clearly, the result variable could be eliminated and color used instead, like this:

) {
   color = "Foo";
} else {
   color = "Fie";
}
System.out.println("Color is " + color);]]>

Surprisingly, IDEA didn't have an inspection for this. At least, I
didn't find one. Does it exist? Do we need a JIRA item?

/Mikael

3 comments

Hmmm. I would have thought "redundant local variable" would have caught
this, but apparently not.

0

Good suggestion. This could be part of the "Redundant Local Variable" inspection. A JIRA request, so this doesn't get lost, would be nice.

0

Please sign in to leave a comment.