#3701 - fix MissingStaticMethodInNonInstantiatableClass for method local classes

This commit is contained in:
Oleksii Dykov 2022-01-16 00:40:19 +02:00
parent 4ae7e40bad
commit 420505a344
2 changed files with 31 additions and 1 deletions

View File

@ -2547,7 +2547,7 @@ See the property `annotations`.
<property name="xpath">
<value>
<![CDATA[
//ClassOrInterfaceDeclaration[@Nested= false()]
//ClassOrInterfaceDeclaration[@Nested= false() and @Local= false()]
[
(
(: at least one constructor :)

View File

@ -346,6 +346,36 @@ public abstract class MyADT {
return onInt.apply(integer);
}
}
}
]]></code>
</test-code>
<test-code>
<description>#3701 - false positive with method inner class</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Scratch {
public static void main(String[] args) {
Scratch scratch = new Scratch();
scratch.callMethod();
}
void callMethod() {
class InnerClass {
private InnerClass() {
}
void display() {
System.out.println("Works OK!");
}
}
InnerClass innerClass = new InnerClass();
innerClass.display();
}
}
]]></code>
</test-code>