mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make another IG test light
This commit is contained in:
@@ -9,7 +9,7 @@ public class TooBroadScope
|
||||
public void test() {
|
||||
// Example #1
|
||||
{
|
||||
Collection<Integer> list = null; //scope too broad
|
||||
Collection<Integer> <warning descr="Scope of variable 'list' is too broad">list</warning> = null; //scope too broad
|
||||
{
|
||||
list = new ArrayList<Integer>();
|
||||
list.add(new Integer(0));
|
||||
@@ -19,7 +19,7 @@ public class TooBroadScope
|
||||
// Example #2
|
||||
{
|
||||
|
||||
Collection<Integer> list; // scope too broad
|
||||
Collection<Integer> <warning descr="Scope of variable 'list' is too broad">list</warning>; // scope too broad
|
||||
list = new ArrayList<Integer>();
|
||||
list.add(new Integer(0));
|
||||
}
|
||||
@@ -27,14 +27,14 @@ public class TooBroadScope
|
||||
// Example #3
|
||||
{
|
||||
|
||||
Collection<Integer> list = null; // nope
|
||||
Collection<Integer> <warning descr="Scope of variable 'list' is too broad">list</warning> = null; // nope
|
||||
list = new ArrayList<Integer>();
|
||||
list.add(new Integer(0));
|
||||
}
|
||||
}
|
||||
|
||||
public void join() {
|
||||
String test;
|
||||
String <warning descr="Scope of variable 'test' is too broad">test</warning>;
|
||||
test = "asdf";
|
||||
}
|
||||
|
||||
@@ -104,13 +104,13 @@ public class TooBroadScope
|
||||
}
|
||||
|
||||
void forLoop() {
|
||||
int i = 0;
|
||||
int <warning descr="Scope of variable 'i' is too broad">i</warning> = 0;
|
||||
for ( ; i < 10; i++) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
|
||||
void resourceVariable(boolean b) {
|
||||
void resourceVariable(boolean b) throws Exception {
|
||||
try (AutoCloseable ac = null) {
|
||||
if (b) {
|
||||
System.out.println(ac);
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>TooBroadScope.java</file>
|
||||
<line>12</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Scope of variable is too broad</problem_class>
|
||||
<description>Scope of variable <code>list</code> is too broad #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TooBroadScope.java</file>
|
||||
<line>22</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Scope of variable is too broad</problem_class>
|
||||
<description>Scope of variable <code>list</code> is too broad #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TooBroadScope.java</file>
|
||||
<line>30</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Scope of variable is too broad</problem_class>
|
||||
<description>Scope of variable <code>list</code> is too broad #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TooBroadScope.java</file>
|
||||
<line>37</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Scope of variable is too broad</problem_class>
|
||||
<description>Scope of variable <code>test</code> is too broad #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TooBroadScope.java</file>
|
||||
<line>107</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Scope of variable is too broad</problem_class>
|
||||
<description>Scope of variable <code>i</code> is too broad #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+15
-3
@@ -1,10 +1,22 @@
|
||||
package com.siyeh.ig.dataflow;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
|
||||
public class TooBroadScopeInspectionTest extends IGInspectionTestCase {
|
||||
public class TooBroadScopeInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/dataflow/scope", new TooBroadScopeInspection());
|
||||
public void testTooBroadScope() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new TooBroadScopeInspection();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/scope";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user