mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make IG test light
This commit is contained in:
+9
-9
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
-51
@@ -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>
|
||||
+11
-4
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user