make IG test light

This commit is contained in:
Bas Leijdekkers
2015-05-11 11:10:29 +02:00
parent 108ec9a90d
commit ec807588db
6 changed files with 84 additions and 105 deletions
@@ -1,26 +0,0 @@
package com.siyeh.igtest.threading.spins;
class WhileLoopSpinsOnField
{
private int quantity_;
public static void main(final String[] args)
{
final WhileLoopSpinsOnField wlsof = new WhileLoopSpinsOnField();
wlsof.countdown();
}
private WhileLoopSpinsOnField()
{
quantity_ = 10;
}
private void countdown()
{
while (quantity_ != 0)
{
System.out.println(quantity_);
quantity_--;
}
}
}
@@ -1,26 +0,0 @@
package com.siyeh.igtest.threading.spins;
import java.io.InputStream;
import java.io.IOException;
class WhileLoopSpinsOnFieldFalsePositive {
private InputStream source;
private long remaining;
WhileLoopSpinsOnFieldFalsePositive(InputStream source) {
if (source == null) {
throw new NullPointerException("source is null");
}
this.source = source;
remaining = 0L;
}
public long nextElement() throws IOException {
while (remaining > 0) {
remaining -= source.skip(remaining);
}
return -1L;
}
}
@@ -1,23 +0,0 @@
package com.siyeh.igtest.threading.spins;
public class WhileLoopSpinsOnFieldInspection
{
private Object test = null;
private int testInt = 3;
private volatile int testVolatileInt = 3;
public void foo()
{
while(test!=null);
while(test!=null)
{
System.out.println("");
}
while(testInt!=3)
{
}
while(testVolatileInt!=3);
}
}
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>WhileLoopSpinsOnFieldInspection.java</file>
<line>11</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">While loop spins on field</problem_class>
<description>&lt;code&gt;while&lt;/code&gt; loop spins on field #loc</description>
</problem>
<problem>
<file>WhileLoopSpinsOnFieldInspection.java</file>
<line>12</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">While loop spins on field</problem_class>
<description>&lt;code&gt;while&lt;/code&gt; loop spins on field #loc</description>
</problem>
<problem>
<file>WhileLoopSpinsOnFieldInspection.java</file>
<line>16</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">While loop spins on field</problem_class>
<description>&lt;code&gt;while&lt;/code&gt; loop spins on field #loc</description>
</problem>
</problems>
@@ -0,0 +1,72 @@
package com.siyeh.igtest.threading.while_loop_spins_on_field;
import java.io.IOException;
import java.io.InputStream;
public class WhileLoopSpinsOnField
{
private Object test = null;
private int testInt = 3;
private volatile int testVolatileInt = 3;
public void foo()
{
<warning descr="'while' loop spins on field">while</warning>(test!=null);
<warning descr="'while' loop spins on field">while</warning>(test!=null)
{
System.out.println("");
}
<warning descr="'while' loop spins on field">while</warning>(testInt!=3)
{
}
while(testVolatileInt!=3);
}
}
class WhileLoopSpinsOnFieldFalsePositive {
private InputStream source;
private long remaining;
WhileLoopSpinsOnFieldFalsePositive(InputStream source) {
if (source == null) {
throw new NullPointerException("source is null");
}
this.source = source;
remaining = 0L;
}
public long nextElement() throws IOException {
while (remaining > 0) {
remaining -= source.skip(remaining);
}
return -1L;
}
}
class WhileLoopSpinsOnField2
{
private int quantity_;
public static void main(final String[] args)
{
final WhileLoopSpinsOnField2 wlsof = new WhileLoopSpinsOnField2();
wlsof.countdown();
}
private WhileLoopSpinsOnField2()
{
quantity_ = 10;
}
private void countdown()
{
while (quantity_ != 0)
{
System.out.println(quantity_);
quantity_--;
}
}
}
@@ -1,11 +1,18 @@
package com.siyeh.ig.threading;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class WhileLoopSpinsOnFieldInspectionTest extends IGInspectionTestCase {
public class WhileLoopSpinsOnFieldInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/threading/spins",
new WhileLoopSpinsOnFieldInspection());
public void testWhileLoopSpinsOnField() throws Exception {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new WhileLoopSpinsOnFieldInspection();
}
}