IntelliJ IDEA: What is the inspection name "Unnecessary Local Variable"?

I want to perform a specific validation of a Java project. I see that this check works in real time in the edit window. But when I use "Analysis → Run test by name", I can not find this test. Actually there is one with the same name, but it is for JavaScript (I tried, although it did not work, as expected). Can someone tell me the exact name of the inspection I need or teach me how to figure it out?

Here is a sample code:

private Integer getInteger(){
    //x on the line below will be highlighted by inspection saying
    // "Local variable 'x' is redundant more... (Ctrl+F1)"
    Integer x = 5;
    return x;
}

Update: I was able to run the required scan using a workaround. I created a test case as described above, then pressed Alt + Enter on the selected area, then the right arrow key and selected "Run Test". enter image description here This works, but it is still unclear how to perform the same checks using "Analysis -> Run test by name"

+3
source share
4 answers

This is caused by an error that was fixed in IntelliJ IDEA 14.

0
source

I get a "Local Variable" I am "redundant message" (and "yellow" analysis) when I enter this code:

public int testMe()
{
   int i = 5;  // The 'i' is highlighted
   return i;
}

( "" , ), :

@SuppressWarnings("UnnecessaryLocalVariable")
public int testMe()
{
   int i = 5;
   return i;
}

" ". , , .

Warning Description         Warning Name
Redundant local variable    UnnecessaryLocalVariable
+2

IntelliJ IDEA 12.1.5 Redundant local variable, .

x , , .

Integer x = 5;
return x;

return 5;

, " ", return 5;, (private static final Integer X = 5;)

+2

It is called an "Unused local variable."

EDIT: Is this the "redundant local variable" you are looking for?

0
source

All Articles