Merge branch 'pr-821'
This commit is contained in:
@ -55,6 +55,8 @@ at <https://pmd.github.io/latest/>.
|
|||||||
* java-bestpractices
|
* java-bestpractices
|
||||||
* [#783](https://github.com/pmd/pmd/issues/783): \[java] GuardLogStatement regression
|
* [#783](https://github.com/pmd/pmd/issues/783): \[java] GuardLogStatement regression
|
||||||
* [#800](https://github.com/pmd/pmd/issues/800): \[java] ForLoopCanBeForeach NPE when looping on `this` object
|
* [#800](https://github.com/pmd/pmd/issues/800): \[java] ForLoopCanBeForeach NPE when looping on `this` object
|
||||||
|
* java-codestyle
|
||||||
|
* [#817](https://github.com/pmd/pmd/issues/817): \[java] UnnecessaryModifierRule crashes on valid code
|
||||||
* java-design
|
* java-design
|
||||||
* [#785](https://github.com/pmd/pmd/issues/785): \[java] NPE in DataClass rule
|
* [#785](https://github.com/pmd/pmd/issues/785): \[java] NPE in DataClass rule
|
||||||
|
|
||||||
|
@ -150,11 +150,13 @@ public class UnnecessaryModifierRule extends AbstractJavaRule {
|
|||||||
private boolean isSafeVarargs(final ASTMethodDeclaration node) {
|
private boolean isSafeVarargs(final ASTMethodDeclaration node) {
|
||||||
for (final ASTAnnotation annotation : node.jjtGetParent().findChildrenOfType(ASTAnnotation.class)) {
|
for (final ASTAnnotation annotation : node.jjtGetParent().findChildrenOfType(ASTAnnotation.class)) {
|
||||||
final Node childAnnotation = annotation.jjtGetChild(0);
|
final Node childAnnotation = annotation.jjtGetChild(0);
|
||||||
if (childAnnotation instanceof ASTMarkerAnnotation
|
if (childAnnotation instanceof ASTMarkerAnnotation) {
|
||||||
&& SafeVarargs.class.isAssignableFrom(((ASTMarkerAnnotation) childAnnotation).getType())) {
|
final ASTMarkerAnnotation marker = (ASTMarkerAnnotation) childAnnotation;
|
||||||
|
if (marker.getType() != null && SafeVarargs.class.isAssignableFrom(marker.getType())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -585,6 +585,16 @@ public class Foo {
|
|||||||
// do something on fw
|
// do something on fw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description>#817 [java] UnnecessaryModifierRule crashes on valid code</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
class Foo {
|
||||||
|
@Bar
|
||||||
|
final void method() { }
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
Reference in New Issue
Block a user