make IG test light

This commit is contained in:
Bas Leijdekkers
2015-08-14 22:15:05 +02:00
parent a65f201239
commit bf85d491a8
3 changed files with 17 additions and 43 deletions
@@ -2,13 +2,13 @@ package com.siyeh.igtest.migration.while_can_be_foreach;
import java.util.*;
public class WhileCanBeForeachInspection {
public class WhileCanBeForeach {
public int baz() {
int total = 0;
final List ints = new ArrayList();
Iterator iterator = ints.iterator();
while ( iterator.hasNext()) {
<warning descr="'while' loop replaceable with 'foreach'">while</warning> ( iterator.hasNext()) {
total += (Integer) iterator.next();
}
return total;
@@ -18,7 +18,7 @@ public class WhileCanBeForeachInspection {
int total = 0;
final List ints = new ArrayList();
Iterator iterator = ints.iterator();
while ( iterator.hasNext()) {
<warning descr="'while' loop replaceable with 'foreach'">while</warning> ( iterator.hasNext()) {
total += (Integer) iterator.next();
}
iterator = ints.iterator(); // write use here
@@ -38,7 +38,7 @@ public class WhileCanBeForeachInspection {
void no(Collection pbps, Map tracksToPBP) {
final Iterator pbpsIt = pbps.iterator();
while (pbpsIt.hasNext()) {
<warning descr="'while' loop replaceable with 'foreach'">while</warning> (pbpsIt.hasNext()) {
final String pbp = (String) pbpsIt.next();
final Iterator trackIt = it();
while (trackIt.hasNext()) {
@@ -70,7 +70,7 @@ public class WhileCanBeForeachInspection {
int total = 0;
final List ints = new ArrayList();
ListIterator iterator = ints.listIterator();
while ( iterator.hasNext()) {
<warning descr="'while' loop replaceable with 'foreach'">while</warning> ( iterator.hasNext()) {
final Object next = iterator.next();
total += (Integer) next;
}
@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>WhileCanBeForeachInspection.java</file>
<line>11</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'while' loop replaceable with 'for each'</problem_class>
<description>&lt;code&gt;while&lt;/code&gt; loop replaceable with 'for each'</description>
</problem>
<problem>
<file>WhileCanBeForeachInspection.java</file>
<line>21</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'while' loop replaceable with 'for each'</problem_class>
<description>&lt;code&gt;while&lt;/code&gt; loop replaceable with 'for each'</description>
</problem>
<problem>
<file>WhileCanBeForeachInspection.java</file>
<line>41</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'while' loop replaceable with 'for each'</problem_class>
<description>&lt;code&gt;while&lt;/code&gt; loop replaceable with 'for each'</description>
</problem>
<problem>
<file>WhileCanBeForeachInspection.java</file>
<line>73</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'while' loop replaceable with 'for each'</problem_class>
<description>&lt;code&gt;while&lt;/code&gt; loop replaceable with 'for each' #loc</description>
</problem>
</problems>
@@ -1,11 +1,18 @@
package com.siyeh.ig.migration;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class WhileCanBeForeachInspectionTest extends IGInspectionTestCase {
public class WhileCanBeForeachInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/migration/while_can_be_foreach",
new WhileCanBeForeachInspection());
public void testWhileCanBeForeach() throws Exception {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new WhileCanBeForeachInspection();
}
}