mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-115468 (for loop variables, catch block parameters and resource variables not reported by "local variable or parameter can be final" inspection)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>CatchParameter.java</file>
|
||||
<line>8</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local variable or parameter can be final</problem_class>
|
||||
<description>Parameter <code>e</code> can have <code>final</code> modifier</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.io.*;
|
||||
|
||||
class CatchParameter {
|
||||
|
||||
void m() {
|
||||
try (InputStream in = new FileInputStream("filename")) { // don't warn about 'in' because it is implicitly final
|
||||
} catch (FileNotFoundException | RuntimeException e) { // don't warn about 'e' because it is implicitly final
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>For.java</file>
|
||||
<line>3</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local variable or parameter can be final</problem_class>
|
||||
<description>Variable <code>it</code> can have <code>final</code> modifier</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -0,0 +1,7 @@
|
||||
class For {
|
||||
void f(List<String> list) {
|
||||
for (Iterator<String> it = list.iterator(); it.hasNext();) { // 'it' can be final but not reported
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,11 @@
|
||||
<line>9</line>
|
||||
<description>foo final</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Junk.java</file>
|
||||
<line>13</line>
|
||||
<description>e final</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Junk.java</file>
|
||||
<line>15</line>
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
<line>9</line>
|
||||
<description>foo final</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Junk.java</file>
|
||||
<line>13</line>
|
||||
<description>e final</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Junk.java</file>
|
||||
<line>15</line>
|
||||
|
||||
Reference in New Issue
Block a user