make IG test light

This commit is contained in:
Bas Leijdekkers
2016-02-23 19:24:39 +01:00
parent 2f92c55fc7
commit e62fcc9d2b
3 changed files with 20 additions and 64 deletions
@@ -3,34 +3,34 @@ package com.siyeh.igtest.controlflow.pointless_null_check;
public class PointlessNullCheck {
public void testViolations(Object arg) {
if (arg != null && arg instanceof String) {
if (<warning descr="Unnecessary 'null' check before 'instanceof' expression">arg != null</warning> && arg instanceof String) {
System.out.println("this should trigger a warning");
}
if (null != arg && arg instanceof String) {
if (<warning descr="Unnecessary 'null' check before 'instanceof' expression">null != arg</warning> && arg instanceof String) {
System.out.println("this should trigger a warning");
}
if (arg instanceof String && null != arg) {
if (arg instanceof String && <warning descr="Unnecessary 'null' check before 'instanceof' expression">null != arg</warning>) {
System.out.println("this should trigger a warning");
}
if (arg instanceof String && arg != null) {
if (arg instanceof String && <warning descr="Unnecessary 'null' check before 'instanceof' expression">arg != null</warning>) {
System.out.println("this should trigger a warning");
}
if ((arg instanceof String) && (arg != null)) {
if ((arg instanceof String) && (<warning descr="Unnecessary 'null' check before 'instanceof' expression">arg != null</warning>)) {
System.out.println("this should trigger a warning");
}
if (arg == null || !(arg instanceof String)) {
if (<warning descr="Unnecessary 'null' check before 'instanceof' expression">arg == null</warning> || !(arg instanceof String)) {
System.out.println("this should trigger a warning");
}
if (((arg) != (null)) && ((arg) instanceof String)) {
if ((<warning descr="Unnecessary 'null' check before 'instanceof' expression">(arg) != (null)</warning>) && ((arg) instanceof String)) {
System.out.println("this should trigger a warning");
}
if (arg != null && (arg instanceof String || arg instanceof Integer)) {
if (<warning descr="Unnecessary 'null' check before 'instanceof' expression">arg != null</warning> && (arg instanceof String || arg instanceof Integer)) {
System.out.println("this should trigger a warning");
}
}
@@ -50,7 +50,7 @@ public class PointlessNullCheck {
System.out.println("this should not trigger a warning");
}
if (arg.charAt(5) instanceof String && arg.charAt(5) != null) {
if (arg1.substring(5) instanceof String && arg1.substring(5) != null) {
System.out.println("this should not trigger a warning");
}
@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>PointlessNullCheck.java</file>
<line>6</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>10</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>14</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>18</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>22</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>26</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>30</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless null check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
<problem>
<file>PointlessNullCheck.java</file>
<line>33</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Pointless 'null' check</problem_class>
<description>Unnecessary 'null' check</description>
</problem>
</problems>
@@ -1,6 +1,8 @@
package com.siyeh.ig.controlflow;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
/**
* Unit test for PointlessNullCheckInspection.
@@ -9,10 +11,15 @@ import com.siyeh.ig.IGInspectionTestCase;
* @author Etienne Studer
* @author Hamlet D'Arcy
*/
public class PointlessNullCheckInspectionTest extends LightInspectionTestCase {
public class PointlessNullCheckInspectionTest extends IGInspectionTestCase {
public void testPointlessNullCheck() {
doTest();
}
public void test() throws Exception {
doTest("com/siyeh/igtest/controlflow/pointless_null_check", new PointlessNullCheckInspection());
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new PointlessNullCheckInspection();
}
}