do not flag dead code if custom JUnit runner is used (IDEA-25444)

This commit is contained in:
anna
2009-10-29 12:40:03 +03:00
parent 18839484a5
commit 876dc8587e
78 changed files with 646 additions and 2 deletions
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>A.java</file>
<line>2</line>
<description>Constructor is never used</description>
</problem>
</problems>
@@ -0,0 +1,4 @@
class B {
A a=new A(0);
}
@@ -0,0 +1,8 @@
class A {
A() {
}
A(int k) {
System.out.println(k);
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,3 @@
class B extends A {
}
@@ -0,0 +1,5 @@
abstract class A {
A() {
}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,5 @@
public class External {
{
new Test();
}
}
@@ -0,0 +1,6 @@
public class Test implements java.io.Serializable {
private void writeObject(java.io.ObjectOutputStream out) {}
private void readObject(java.io.ObjectInputStream in) {}
public Object writeReplace() { return null; }
public Object readResolve() { return null; }
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="p1.Form">
<component id="566a6" class="javax.swing.JLabel" binding="myLabel">
<constraints>
<xy x="167" y="116" width="33" height="16"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
</constraints>
<properties>
<text value="Label"/>
</properties>
</component>
</form>
@@ -0,0 +1,8 @@
package p1;
public class Form {
private JLabel myLabel;
private void createUIComponents() {
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,9 @@
@Annotated
public class Test {
@Annotated
public void foo(){}
@Annotated
public int myPublicField;
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,6 @@
import java.lang.annotation.*;
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
public @interface Test {
String value() default "";
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,5 @@
public class A {
public A() {
}
}
@@ -0,0 +1,5 @@
public class B implements I{
public void projectOpened() {
new A();
}
}
@@ -0,0 +1,3 @@
public interface I {
void projectOpened();
}
@@ -0,0 +1,6 @@
class Test {
public static void main(String[] args){
I i = null;
i.projectOpened();
}
}
@@ -0,0 +1 @@
<component>B</component>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,18 @@
public class A {
public static void main(String[] args) {
new A();
}
private void a(){
}
private void b(){
a();
}
@java.lang.SuppressWarnings({"UnusedDeclaration"})
private void c(){
b();
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,4 @@
public class A {
public A(int i) {
}
}
@@ -0,0 +1,5 @@
public class B {
public static void main(String[] args){
System.out.println(new A(1));
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,9 @@
public class Test {
public static void main(String[] args){
System.out.println(new A(1));
}
private class A {
public A(int i){}
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,8 @@
package test;
public class AMatcher implements Matcher{
private static final BracePair [] PAIRS = new BracePair[]{new BracePair()};
public BracePair[] getPairs() {
return PAIRS;
}
}
@@ -0,0 +1,7 @@
package test;
public class BracePair {
public BracePair() {
}
}
@@ -0,0 +1,5 @@
package test;
public interface Matcher {
BracePair[] getPairs();
}
@@ -0,0 +1,12 @@
package test;
public class Test {
public Test(Matcher m) {
BracePair[] bracePairs = m.getPairs();
}
public static void main(String[] args) {
System.out.println(new Test(new AMatcher()));
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,7 @@
public void Test1 {
void foo() {
if (Test.FIRST.invert() != Test.SECOND) {
//assert
}
}
}
@@ -0,0 +1,8 @@
public enum Test
{
FIRST, SECOND;
public Test invert() {
return this == FIRST ? SECOND : FIRST;
}
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>14</line>
<entry_point TYPE="method" FQNAME="Test void notATest()"/>
<description>Method is never used.</description>
</problem>
<problem>
<file>Test.java</file>
<line>8</line>
<entry_point TYPE="method" FQNAME="Test void testSmth()"/>
<description>Method is never used.</description>
</problem>
</problems>
@@ -0,0 +1,3 @@
public interface I {
A create();
}
@@ -0,0 +1,5 @@
public class IImpl extends I {
public A create() {
return new A();
}
}
@@ -0,0 +1,15 @@
public class Test {
public static junit.framework.Test suite() {
I i = new IImpl();
A a = i.create();
return null;
}
public void testSmth() {}
public void setUp() {}
public void tearDown(){}
public void notATest(){}
}
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -0,0 +1,10 @@
@org.junit.runner.RunWith(UnresolvedRunner.class)
public class Test {
public void testSmth() {}
public void setUp() {}
public void tearDown(){}
public void notATestButCanBeRunnedWithCustomRunner(){}
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>A.java</file>
<line>2</line>
<problem_class>unused declaration</problem_class>
<description>Method has usage(s) but they all belong to recursive calls chain that has no members reachable from entry points.</description>
</problem>
<problem>
<file>A.java</file>
<line>5</line>
<problem_class>unused declaration</problem_class>
<description>Method has usage(s) but they all belong to recursive calls chain that has no members reachable from entry points.</description>
</problem>
</problems>
@@ -0,0 +1,9 @@
public class A {
private void a(){
b();
}
private void b(){
a();
}
}
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>2</line>
<description>Field has no usages.</description>
</problem>
</problems>
@@ -0,0 +1 @@
<root>Test</root>
@@ -0,0 +1,3 @@
public class Test {
public static final String LOG = Test.class.getName();
}
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>A.java</file>
<line>3</line>
<problem_class>unused declaration</problem_class>
<description>Class is not instantiated.</description>
</problem>
</problems>
@@ -0,0 +1,8 @@
class A {
}
class B{
private void b(){
new B();
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,3 @@
interface Interface {
int[] getField();
}
@@ -0,0 +1,16 @@
public class Test implements Interface{
public static int[] myField = new int[] {init()};
public static int init() {
return 1;
}
public static void main(String[] args){
Interface i = new Test();
System.out.println(i.getField());
}
public int[] getField() {
return myField;
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,3 @@
interface Interface {
int getField();
}
@@ -0,0 +1,16 @@
public class Test implements Interface{
public int myField = init();
public int init() {
return 1;
}
public static void main(String[] args){
Interface i = new Test();
System.out.println(i.getField());
}
public int getField() {
return myField;
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,10 @@
public class A {
public static void main(String[] args) {
B.b();
}
private static class B{
public static B b(){
return new B();
}
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,5 @@
public class A {
public A() {
}
}
@@ -0,0 +1 @@
<component>A</component>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,5 @@
public class Main {
public static void main(String args[]) {
Singleton.getInstance();
}
}
@@ -0,0 +1,7 @@
pubic class Singleton {
private static Singleton ourInstance = new Singleton();
public Singleton getInstance() {
return ourInstance;
}
}
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>A.java</file>
<line>3</line>
<problem_class>unused declaration</problem_class>
<description>Method is never used.</description>
</problem>
</problems>
@@ -0,0 +1,7 @@
public class A {
private A(){}
public static A getInstance(){
return new A();
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,4 @@
class B {
A a=new A(0);
}
@@ -0,0 +1,9 @@
class A {
@java.lang.SuppressWarnings({"UnusedDeclaration"})
A() {
}
A(int k) {
System.out.println(k);
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,8 @@
class A {
@java.lang.SuppressWarnings({"UnusedDeclaration"})
A() {
new B();
}
}
@@ -0,0 +1,3 @@
class B {
B(){}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -0,0 +1,8 @@
class A {
@java.lang.SuppressWarnings({"UnusedDeclaration"})
A() {
B bb = new B();
}
}
@@ -0,0 +1,3 @@
class B {
}