[java] Improve UnnecessaryModifier explanation
Merge branch 'pr-1380'
This commit is contained in:
@ -167,9 +167,14 @@ public class UnnecessaryModifierRule extends AbstractJavaRule {
|
||||
reportUnnecessaryModifiers(data, node, Modifier.PUBLIC, "members of " + getPrintableNodeKind(node.getEnclosingTypeDeclaration()) + " types are implicitly public");
|
||||
}
|
||||
|
||||
if ((node.isInterface() || isParentInterfaceOrAnnotation) && node.isStatic()) {
|
||||
// a static interface or class nested within an interface
|
||||
reportUnnecessaryModifiers(data, node, Modifier.STATIC, "types nested within an interface type are implicitly static");
|
||||
if (node.isStatic()) {
|
||||
if (node.isInterface()) {
|
||||
// a static interface
|
||||
reportUnnecessaryModifiers(data, node, Modifier.STATIC, "member interfaces are implicitly static");
|
||||
} else if (isParentInterfaceOrAnnotation) {
|
||||
// a type nested within an interface
|
||||
reportUnnecessaryModifiers(data, node, Modifier.STATIC, "types nested within an interface type are implicitly static");
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -680,7 +680,7 @@ enum Foo {
|
||||
<description>Static Modifier on interface</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-messages>
|
||||
<message>Unnecessary modifier 'static' on interface 'Bar': types nested within an interface type are implicitly static</message>
|
||||
<message>Unnecessary modifier 'static' on interface 'Bar': member interfaces are implicitly static</message>
|
||||
</expected-messages>
|
||||
<code><![CDATA[
|
||||
class Foo{
|
||||
@ -690,4 +690,19 @@ class Foo{
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>Static Modifier on interface</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-messages>
|
||||
<message>Unnecessary modifier 'static' on class 'Foo': types nested within an interface type are implicitly static</message>
|
||||
</expected-messages>
|
||||
<code><![CDATA[
|
||||
public interface Bar {
|
||||
void method() {
|
||||
}
|
||||
static class Foo {}
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user