diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java
index 4dbd0bfaff47..f742c291ad8a 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach/ForCanBeForEach.java
@@ -1,18 +1,16 @@
package com.siyeh.igtest.migration.foreach;
-import com.siyeh.igtest.verbose.OuterClass;
-
import java.util.*;
public class ForCanBeForEach {
public void foo(int[] is) {
- for (int i = 0; i < is.length; i++) {
+ for (int i = 0; i < is.length; i++) {
}
}
public void test(Collection bars){
- for(Iterator it = bars.iterator(); it .hasNext();){
+ for(Iterator it = bars.iterator(); it .hasNext();){
final List bar = it.next();
bar.size();
}
@@ -21,7 +19,7 @@ public class ForCanBeForEach {
public int foo(){
final int[] ints = new int[3];
int total = 0;
- for(int i = 0; i < ints.length; i++){
+ for(int i = 0; i < ints.length; i++){
final int j = ints[i];
total += j;
}
@@ -31,7 +29,7 @@ public class ForCanBeForEach {
public int bar(){
final int[] ints = new int[3];
int total = 0;
- for(int i = 0; i < ints.length; i++){
+ for(int i = 0; i < ints.length; i++){
total += ints[i];
}
return total;
@@ -40,7 +38,7 @@ public class ForCanBeForEach {
public int baz(){
int total = 0;
final List ints = new ArrayList();
- for(Iterator iterator = ints.iterator(); iterator.hasNext();){
+ for(Iterator iterator = ints.iterator(); iterator.hasNext();){
final Integer value = (Integer) iterator.next();
total += value.intValue();
}
@@ -50,7 +48,7 @@ public class ForCanBeForEach {
public int bazoom(){
int total = 0;
final List ints = new ArrayList();
- for(Iterator iterator = ints.iterator(); iterator.hasNext();){
+ for(Iterator iterator = ints.iterator(); iterator.hasNext();){
final Integer value = iterator.next();
total += value.intValue();
}
@@ -60,7 +58,7 @@ public class ForCanBeForEach {
public int wildBazoom(){
int total = 0;
final List extends Integer> ints = new ArrayList();
- for(Iterator extends Integer> iterator = ints.iterator();
+ for(Iterator extends Integer> iterator = ints.iterator();
iterator.hasNext();){
final Integer value = iterator.next();
total += value.intValue();
@@ -80,7 +78,7 @@ public class ForCanBeForEach {
Map m = new HashMap();
m.put("123", 123);
m.put("456", 456);
- for(Iterator> iterator = m.entrySet()
+ for(Iterator> iterator = m.entrySet()
.iterator(); iterator.hasNext();){
Map.Entry entry = iterator.next();
System.out.println(entry.getKey() + "=" + entry.getValue());
@@ -103,7 +101,7 @@ public class ForCanBeForEach {
public void boom2(){
OuterClass.UnnecessaryEnumModifier2Inspection[] inners = new OuterClass.UnnecessaryEnumModifier2Inspection[3];
- for(int i = 0; i < inners.length; i++){
+ for(int i = 0; i < inners.length; i++){
OuterClass.UnnecessaryEnumModifier2Inspection inner = inners[i];
System.out.println(inner);
}
@@ -125,7 +123,7 @@ public class ForCanBeForEach {
}
public void quickFixBoom(List numbers) {
- for (int i = 0; i < (numbers.size()); i++) {
+ for (int i = 0; i < (numbers.size()); i++) {
System.out.println("numbers[i]: " + numbers.get(i));
}
}
@@ -181,7 +179,7 @@ public class ForCanBeForEach {
void sizeInVariable(List ls) {
int size = ls.size();
- for (int i = (0); (i < (size)); (i)++) {
+ for (int i = (0); (i < (size)); (i)++) {
Object o = ls.get(i);
System.out.println("o = " + o);
}
@@ -190,7 +188,7 @@ public class ForCanBeForEach {
class X extends ArrayList {
void foo() {
- for (int i = 0; i < size(); i++) {
+ for (int i = 0; i < size(); i++) {
this.get(i);
}
}
@@ -207,7 +205,7 @@ public class ForCanBeForEach {
int strange() {
int total = 0;
final List ints = new ArrayList();
- for (ListIterator l = ints.listIterator(); l.hasNext(); ) {
+ for (ListIterator l = ints.listIterator(); l.hasNext(); ) {
System.out.println(l.next());
}
return total;
@@ -228,18 +226,18 @@ public class ForCanBeForEach {
}
void listIteration(List l) {
- for (Iterator i = l.listIterator(); l.hasNext(); ) {
- if ("sit".equals(l.next())) {
+ for (ListIterator i = l.listIterator(); i.hasNext(); ) {
+ if ("sit".equals(i.next())) {
i.set("stay");
}
}
}
void indexedList(List l) {
- for (int i = 0, max = l.size(); i < max; i++) {
+ for (int i = 0, max = l.size(); i < max; i++) {
System.out.println(l.get(i));
}
- for (int i = (0), max = (l.size()); ((max) > (i)); (i)++) {
+ for (int i = (0), max = (l.size()); ((max) > (i)); (i)++) {
System.out.println(l.get(i)); }
for (int i = 0; i < l.size(); i++) {}
}
@@ -249,14 +247,14 @@ public class ForCanBeForEach {
}
static class User {{
String[] strings = Constants.STRINGS;
- for (int i = 0, length = strings.length; i < length; i++) { // should warn here
+ for (int i = 0, length = strings.length; i < length; i++) { // should warn here
String s = strings[i];
System.out.println(s);
}
}}
public void food(int[] is) {
- for (int i = 0; is.length > i; i++) {
+ for (int i = 0; is.length > i; i++) {
}
for (int i = 0, j = 10; i < is.length; i++) {
}
@@ -268,11 +266,20 @@ public class ForCanBeForEach {
}
}
- class X {
- void m(T ts) {
- for (int i = 0; i < ts.length; i++) {
+ class XX {
+ void m(T[] ts) {
+ for (int i = 0; i < ts.length; i++) {
System.out.println();
}
}
}
}
+class OuterClass
+{
+ public static enum UnnecessaryEnumModifier2Inspection {
+ Red, Green, Blue;
+
+ private UnnecessaryEnumModifier2Inspection() {
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/verbose/OuterClass.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/verbose/OuterClass.java
deleted file mode 100644
index 0e360089f1bd..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/verbose/OuterClass.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.siyeh.igtest.verbose;
-
-public class OuterClass
-{
- public static enum UnnecessaryEnumModifier2Inspection {
- Red, Green, Blue;
-
- private UnnecessaryEnumModifier2Inspection() {
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java
index 66866ddc06ef..fe513136456d 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/migration/ForCanBeForeachInspectionTest.java
@@ -1,12 +1,21 @@
package com.siyeh.ig.migration;
-import com.siyeh.ig.IGInspectionTestCase;
-import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
-public class ForCanBeForeachInspectionTest extends IGInspectionTestCase {
+public class ForCanBeForeachInspectionTest extends LightInspectionTestCase {
- public void test() throws Exception {
- doTest("com/siyeh/igtest/migration/foreach",
- new LocalInspectionToolWrapper(new ForCanBeForeachInspection()), "java 1.5");
+ public void testForCanBeForEach() {
+ doTest();
+ }
+
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new ForCanBeForeachInspection();
+ }
+
+ @Override
+ protected String getBasePath() {
+ return "/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/foreach";
}
}
\ No newline at end of file