[jvm-inspections] Move Java test data for EmptyMethodInspection to JVM module; suppression top-level test

GitOrigin-RevId: 645e9ea69d7d2c81d65bfe73d6e74dc30c4e22e6
This commit is contained in:
Tagir Valeev
2024-01-30 08:55:34 +01:00
committed by intellij-monorepo-bot
parent 3e474191e3
commit 0ceb02ac9a
31 changed files with 17 additions and 4 deletions

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>MyListener.java</file>
<line>2</line>
<description>empty</description>
</problem>
<problem>
<file>MyListener.java</file>
<line>4</line>
<description>empty</description>
</problem>
<problem>
<file>MyAdapterUsage.java</file>
<line>2</line>
<description>only calls super</description>
</problem>
</problems>

View File

@@ -0,0 +1,5 @@
public class MyAdapter implements MyListener {
public void myListen1() {}
public void myListen2() {}
public void myListen3() {}
}

View File

@@ -0,0 +1,8 @@
public class MyAdapterUsage extends MyAdapter {
public void myListen1(){
super.myListen1();
}
public void myListen2(){
System.out.println("code here");
}
}

View File

@@ -0,0 +1,5 @@
public interface MyListener {
void myListen1();
void myListen2();
void myListen3();
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>2</line>
<description>All implementations of this method are empty</description>
</problem>
</problems>

View File

@@ -0,0 +1,20 @@
interface ITest {
int foo();
}
public class Test implements ITest {
ITest lambda = () -> {};
@Override
public int foo() {
}
public int bar() {
return 1;
}
}
class Sub extends Test {
ITest lambda1 = () -> super.foo();
ITest lambda2 = () -> { return super.foo(); };
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Derived.java</file>
<line>16</line>
<description>Empty method overrides empty method</description>
</problem>
</problems>

View File

@@ -0,0 +1,17 @@
package p2;
class A {
public void foo(){
System.out.println("");
}
}
class B extends A {
@Override
public void foo() {}
}
class C extends B {
@Override
public void foo() {}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Base.java</file>
<line>2</line>
<description>empty</description>
</problem>
<problem>
<file>Base.java</file>
<line>4</line>
<description>empty</description>
</problem>
</problems>

View File

@@ -0,0 +1,5 @@
public class Derived extends Base {
public void foo() {}
public void bar() { System.out.println("Hello"); }
public void foobar() { super.foobar(); }
}

View File

@@ -0,0 +1,5 @@
public class Base {
public void foo() {}
public void bar() {}
public void foobar() {}
}

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>6</line>
<entry_point TYPE="method" FQNAME="Test$1 void a()"/>
<problem_class>Empty method</problem_class>
<description>The method is empty</description>
</problem>
<problem>
<file>Test.java</file>
<line>13</line>
<entry_point TYPE="method" FQNAME="Test$5A$1 void aa()"/>
<problem_class>Empty method</problem_class>
<description>The method is empty</description>
</problem>
<problem>
<file>Test.java</file>
<line>20</line>
<entry_point TYPE="method" FQNAME="Test$5A$3A1$1 void aa1()"/>
<problem_class>Empty method</problem_class>
<description>The method is empty</description>
</problem>
<problem>
<file>Test.java</file>
<line>32</line>
<entry_point TYPE="method" FQNAME="Test.B$1 void bb()"/>
<problem_class>Empty method</problem_class>
<description>The method is empty</description>
</problem>
</problems>

View File

@@ -0,0 +1,36 @@
public class Test {
public void foo() {
Runnable r = new Runnable() {
public void run(){
}
private void a(){}
}
class A {
void a(){
Runnable a = new Runnable() {
public void run(){
}
private void aa(){}
}
class A1 {
void a1(){
Runnable a1 = new Runnable() {
public void run(){
}
private void aa1(){}
}
}
}
}
}
}
class B {
void b() {
Runnable b = new Runnable() {
public void run(){
}
private void bb(){}
}
}
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
</problems>

View File

@@ -0,0 +1,14 @@
interface ITest {
void foo();
default void bar() {
}
}
public class Test implements ITest {
ITest lambda = () -> super.bar();
@Override
public void foo() {
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Base.java</file>
<line>2</line>
<description>empty</description>
</problem>
<problem>
<file>Defaults.java</file>
<line>28</line>
<description>Method only calls its super</description>
</problem>
</problems>

View File

@@ -0,0 +1,3 @@
public class Base {
public void foo() {}
}

View File

@@ -0,0 +1,37 @@
interface Interface1 {
default void foo() { System.out.println("Interface1.foo()"); }
}
interface Interface2 {
default void foo() { System.out.println("Interface2.foo()"); }
}
interface Interface3 extends Interface1, Interface2 {
default void foo() {
Interface1.super.foo();
Interface2.super.foo();
}
}
interface Interface4 {
void foo();
}
interface Interface5 extends Interface1, Interface4 {
@Override default void foo() { Interface1.super.foo(); }
}
interface Interface6 extends Interface1 {
void foo();
}
interface Interface7 extends Interface1, Interface6 {
@Override default void foo() { Interface1.super.foo(); }
}
class Main {
public static void main(String args[]) {
new Interface5() { }.foo();
new Interface7() { }.foo();
}
}

View File

@@ -0,0 +1,5 @@
public class Derived extends Base {
public void foo() {
super.foo();
}
}

View File

@@ -0,0 +1,12 @@
class ManySuperCalls {
public void foo() {
System.out.println();
}
}
class ManySuperCallsImpl extends ManySuperCalls {
public void foo() {
super.foo();
super.foo();
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Base.java</file>
<line>2</line>
<description>empty</description>
<entry_point TYPE="method" FQNAME="Base void foo()" />
</problem>
</problems>

View File

@@ -0,0 +1,3 @@
public class Base {
public void foo() {}
}

View File

@@ -0,0 +1,5 @@
public class Derived extends Base {
public void foo() {
super.foo();
}
}

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>

View File

@@ -0,0 +1,4 @@
package p1;
public class Base {
protected void foo() {System.out.println("");}
}

View File

@@ -0,0 +1,7 @@
package p2;
import p1;
public class Derived extends Base {
protected void foo() {
super.foo();
}
}

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>

View File

@@ -0,0 +1,4 @@
package p1;
public class Base {
public void foo() {System.out.println("");}
}

View File

@@ -0,0 +1,7 @@
package p2;
import p1;
public class Derived extends p1.Base {
public synchronized void foo() {
super.foo();
}
}