make IG test light
authorBas Leijdekkers <basleijdekkers@gmail.com>
Thu, 10 Nov 2016 14:44:33 +0000 (15:44 +0100)
committerBas Leijdekkers <basleijdekkers@gmail.com>
Sat, 12 Nov 2016 07:18:17 +0000 (08:18 +0100)
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/MismatchedArrayReadWrite.java
plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/expected.xml [deleted file]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/MismatchedArrayReadWriteInspectionTest.java

index 33683aaa4d1fa02ca6264f70512b66238737dbeb..394723ffddaff4ca51a607ec7ef4b709f67ee129 100644 (file)
@@ -1,8 +1,8 @@
 package com.siyeh.igtest.bugs.mismatched_array_read_write;
 
 public class MismatchedArrayReadWrite {
-    private int[] foo = new int[3];
-    private int[] bar;
+    private int[] <warning descr="Contents of array 'foo' are written to, but never read">foo</warning> = new int[3];
+    private int[] <warning descr="Contents of array 'bar' are read, but never written to">bar</warning>;
 
     public void bar()
     {
@@ -11,13 +11,13 @@ public class MismatchedArrayReadWrite {
 
     public void bar2()
     {
-        final int[] barzoom = new int[3];
+        final int[] <warning descr="Contents of array 'barzoom' are written to, but never read">barzoom</warning> = new int[3];
         barzoom[2] = 3;
     }
 
     public void bar3()
     {
-        final int[] barzoom = new int[3];
+        final int[] <warning descr="Contents of array 'barzoom' are read, but never written to">barzoom</warning> = new int[3];
         int baz = barzoom[2];
     }
 
@@ -29,13 +29,13 @@ public class MismatchedArrayReadWrite {
 
     public int bar5()
     {
-        final int[] barzoom = new int[3];
+        final int[] <warning descr="Contents of array 'barzoom' are read, but never written to">barzoom</warning> = new int[3];
         return barzoom[3];
     }
 
     public void bar6()
     {
-        final int[] barzoom = new int[3];
+        final int[] <warning descr="Contents of array 'barzoom' are read, but never written to">barzoom</warning> = new int[3];
         System.out.println(barzoom[3]);
     }
 
@@ -87,17 +87,17 @@ class Test{
     }
 
     void foo1() {
-        final int[] barzoom = {};
+        final int[] <warning descr="Contents of array 'barzoom' are written to, but never read">barzoom</warning> = {};
         barzoom[2] = 3;
     }
 
     void foo2() {
-        final int[] barzoom = new int[]{};
+        final int[] <warning descr="Contents of array 'barzoom' are written to, but never read">barzoom</warning> = new int[]{};
         barzoom[2] = 3;
     }
 
     void foo3(Object[] otherArr) {
-        Object[] arr = otherArr.clone();
+        Object[] <warning descr="Contents of array 'arr' are written to, but never read">arr</warning> = otherArr.clone();
         for (int i = 0; i < 10; i++) arr[i] = i;
     }
 
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_array_read_write/expected.xml
deleted file mode 100644 (file)
index 9acc1e3..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<problems>
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>20</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;barzoom&lt;/code&gt; are read, but never written to #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>32</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;barzoom&lt;/code&gt; are read, but never written to #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>14</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;barzoom&lt;/code&gt; are written to, but never read #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>38</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;barzoom&lt;/code&gt; are read, but never written to #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>5</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;bar&lt;/code&gt; are read, but never written to #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>4</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;foo&lt;/code&gt; are written to, but never read #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>90</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;barzoom&lt;/code&gt; are written to, but never read #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>100</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;arr&lt;/code&gt; are written to, but never read #loc</description>
-  </problem>
-
-  <problem>
-    <file>MismatchedArrayReadWrite.java</file>
-    <line>95</line>
-    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Mismatched read and write of array</problem_class>
-    <description>Contents of array &lt;code&gt;barzoom&lt;/code&gt; are written to, but never read #loc</description>
-  </problem>
-
-</problems>
\ No newline at end of file
index 7f2c306017d11116d73481d9813511b27cb4ca0e..e833ec1f2cbd235fa5242230dac1f3c2169aaad8 100644 (file)
@@ -1,11 +1,43 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.siyeh.ig.bugs;
 
-import com.siyeh.ig.IGInspectionTestCase;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
 
-public class MismatchedArrayReadWriteInspectionTest extends IGInspectionTestCase {
+public class MismatchedArrayReadWriteInspectionTest extends LightInspectionTestCase {
 
-  public void test() throws Exception {
-    doTest("com/siyeh/igtest/bugs/mismatched_array_read_write",
-           new MismatchedArrayReadWriteInspection());
+  public void testMismatchedArrayReadWrite() {
+    doTest();
+  }
+
+  @Nullable
+  @Override
+  protected InspectionProfileEntry getInspection() {
+    return new MismatchedArrayReadWriteInspection();
+  }
+
+  @Override
+  protected String[] getEnvironmentClasses() {
+    return new String[] {
+      "package java.io;" +
+      "public class ObjectStreamField {" +
+      "  public ObjectStreamField(String name, Class<?> type) {}" +
+      "}"
+    };
   }
 }
\ No newline at end of file