make IG test light

This commit is contained in:
Bas Leijdekkers
2014-11-07 15:13:01 +01:00
parent 98887ba079
commit 5de5b00c0e
3 changed files with 32 additions and 160 deletions
@@ -5,18 +5,18 @@ package com.siyeh.igtest.jdk.auto_unboxing;
public class AutoUnboxing {
{
Long someNumber = Long.valueOf(0);
someNumber++;
long l = someNumber + 0;
Long aLong = Long.valueOf(someNumber << 2);
<warning descr="Auto-unboxing 'someNumber'">someNumber</warning>++;
long l = <warning descr="Auto-unboxing 'someNumber'">someNumber</warning> + 0;
Long aLong = Long.valueOf(<warning descr="Auto-unboxing 'someNumber'">someNumber</warning> << 2);
}
public void foo() {
Integer bar = 3;
int baz = new Integer(3);
if (new Integer(3) == 3) {
int baz = <warning descr="Auto-unboxing 'new Integer(3)'">new Integer(3)</warning>;
if (<warning descr="Auto-unboxing 'new Integer(3)'">new Integer(3)</warning> == 3) {
return;
}
if (new Integer(3) + 3 == 3) {
if (<warning descr="Auto-unboxing 'new Integer(3)'">new Integer(3)</warning> + 3 == 3) {
return;
}
Integer x = 3;
@@ -24,17 +24,17 @@ public class AutoUnboxing {
public void bar(Double value) {
if (value > 0.0) {
if (<warning descr="Auto-unboxing 'value'">value</warning> > 0.0) {
return;
}
bazz(value);
bazz(<warning descr="Auto-unboxing 'value'">value</warning>);
}
private void bazz(double value) {
System.out.println("value = " + value);
Boolean c = Boolean.TRUE & false;
Long d = Integer.valueOf(2) & 1L;
Boolean c = <warning descr="Auto-unboxing 'Boolean.TRUE'">Boolean.TRUE</warning> & false;
Long d = <warning descr="Auto-unboxing 'Integer.valueOf(2)'">Integer.valueOf(2)</warning> & 1L;
}
private boolean noWarn(Integer i1, Integer i2) {
@@ -42,11 +42,11 @@ public class AutoUnboxing {
}
void m(Boolean b) {
assert b;
assert <warning descr="Auto-unboxing 'b'">b</warning>;
}
void n(Integer i) {
switch(i) {
switch(<warning descr="Auto-unboxing 'i'">i</warning>) {
case 1: break;
case 2: break;
case 3: break;
@@ -55,26 +55,26 @@ public class AutoUnboxing {
}
void m(Object o, Boolean b, Number n) {
if ((boolean) o) {}
if ((boolean) b) {}
if ((int)n) {}
if ((boolean) <warning descr="Auto-unboxing 'o'">o</warning>) {}
if ((boolean) <warning descr="Auto-unboxing 'b'">b</warning>) {}
if (<error descr="Incompatible types. Found: 'int', required: 'boolean'">(int)<warning descr="Auto-unboxing 'n'">n</warning></error>) {}
}
boolean polyadic() {
return true && Boolean.TRUE && true;
return true && <warning descr="Auto-unboxing 'Boolean.TRUE'">Boolean.TRUE</warning> && true;
}
void n() {
boolean b = Boolean.valueOf(true) == ;
boolean b = Boolean.valueOf(true) ==<error descr="Expression expected"> </error>;
boolean c = Boolean.valueOf(true) ==
Boolean.valueOf(false) ==
Boolean.valueOf(true);
<warning descr="Auto-unboxing 'Boolean.valueOf(true)'">Boolean.valueOf(true)</warning>;
boolean d = Boolean.valueOf(true) ==
Boolean.valueOf(false);
boolean e = Boolean.valueOf(true) ==
boolean e = <warning descr="Auto-unboxing 'Boolean.valueOf(true)'">Boolean.valueOf(true)</warning> ==
false;
boolean f = true ==
Boolean.valueOf(false);
<warning descr="Auto-unboxing 'Boolean.valueOf(false)'">Boolean.valueOf(false)</warning>;
boolean g = Boolean.valueOf(true) == Boolean.valueOf(false) == true;
}
}
@@ -1,136 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>AutoUnboxing.java</file>
<line>8</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;someNumber&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>9</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;someNumber&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>10</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;someNumber&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>15</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;new Integer(3)&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>16</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;new Integer(3)&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>19</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;new Integer(3)&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>27</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;value&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>31</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;value&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>36</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;Boolean.TRUE&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>37</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;Integer.valueOf(2)&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>45</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;b&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>49</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;i&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>58</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;o&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>59</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;b&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>60</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;n&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>64</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;Boolean.TRUE&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>71</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;Boolean.valueOf(true)&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>74</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;Boolean.valueOf(true)&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>AutoUnboxing.java</file>
<line>77</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
<description>Auto-unboxing &lt;code&gt;Boolean.valueOf(false)&lt;/code&gt; #loc</description>
</problem>
</problems>
@@ -1,10 +1,18 @@
package com.siyeh.ig.jdk;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class AutoUnboxingInspectionTest extends IGInspectionTestCase {
public class AutoUnboxingInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/jdk/auto_unboxing", new AutoUnboxingInspection());
public void testAutoUnboxing() {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new AutoUnboxingInspection();
}
}