RedundantArrayForVarargsCallInspectionTest: make it LightInspectionTestCase

This commit is contained in:
Tagir Valeev
2017-05-11 13:22:55 +07:00
parent f56d098ab1
commit 72078f0b1d
19 changed files with 63 additions and 135 deletions
@@ -0,0 +1,7 @@
public enum CheckEnumConstant {
A(<warning descr="Redundant array creation for calling varargs method">new String[]{"1", "2"}</warning>);
CheckEnumConstant(String... ss) {
}
}
@@ -0,0 +1,22 @@
class Generic {
class A {}
class B extends A {}
void f() {
B b = new B();
C<A> l = asC(new A[]{b});
A a = new A();
C<A> m = asC(<warning descr="Redundant array creation for calling varargs method">new A[]{a}</warning>);
}
public static <T> C<T> asC(T... ts) {
return null;
}
class C<T> {}
void m() {
System.out.println(String.format("%s %s", <warning descr="Redundant array creation for calling varargs method">new Object[] {"Z", "X"}</warning>));
}
}
@@ -1,5 +1,5 @@
public class Test {
public class IDEADEV15215 {
public static void main(String[] args) {
foo(new byte[]{ 1, 2, 3 });
@@ -15,6 +15,6 @@ public class Test {
public static void extra(String... args) {
extra(new String[]{"vvv","aaa"});
extra(<warning descr="Redundant array creation for calling varargs method">new String[]{"vvv","aaa"}</warning>);
}
}
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>18</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
</problems>
@@ -0,0 +1,9 @@
public class IDEADEV25923 {
public void foo(Object... params) {}
{
foo(new Object[2]);
foo(<warning descr="Redundant array creation for calling varargs method">new Object[0]</warning>);
}
}
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>7</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
</problems>
@@ -1,9 +0,0 @@
public class Test {
public void foo(Object... params) {}
{
foo(new Object[2]);
foo(new Object[0]);
}
}
@@ -1,5 +1,5 @@
public class IntentionTest {
public IntentionTest() {}
public class NestedArray {
public NestedArray() {}
public void method( Object ... args ) {
for (int i = 0; i < args.length; i++) {
@@ -10,7 +10,7 @@ public class IntentionTest {
public void main(String[] args) {
String[] params = new String[]{ "0", "1" };
method(new Object[]{params});
method(new Object[]{"2", params});
method(new Object[]{params, params});
method(<warning descr="Redundant array creation for calling varargs method">new Object[]{"2", params}</warning>);
method(<warning descr="Redundant array creation for calling varargs method">new Object[]{params, params}</warning>);
}
}
@@ -1,8 +1,8 @@
import java.lang.invoke.MethodHandle;
public class Test {
public class PolymorphicSignature {
public static void main(String[] args) {
public static void main(String[] args) throws Throwable {
MethodHandle meh = null;
meh.invokeExact(new Object[] {});
}
@@ -0,0 +1,9 @@
public class RawArray {
{
try {
String.class.getConstructor(<warning descr="Redundant array creation for calling varargs method">new Class[]{String.class}</warning>);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>3</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
</problems>
@@ -1,7 +0,0 @@
public enum Test {
A(new String[]{"1", "2"});
Test(String... ss) {
}
}
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>10</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
<problem>
<file>Test.java</file>
<line>20</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
</problems>
@@ -1,22 +0,0 @@
class Test {
class A {}
class B extends A {}
void f() {
B b = new B();
C<A> l = asC(new A[]{b});
A a = new A();
C<A> m = asC(new A[]{a});
}
public static <T> C<T> asC(T... ts) {
return null;
}
class C<T> {}
void m() {
System.out.println(String.format("%s %s", new Object[] {"Z", "X"}));
}
}
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>13</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
<problem>
<file>Test.java</file>
<line>14</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
</problems>
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>4</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant array creation</problem_class>
<description>Redundant array creation for calling varargs method</description>
</problem>
</problems>
@@ -1,9 +0,0 @@
public class Test {
{
try {
String.class.getConstructor(new Class[]{String.class});
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}