forked from phoedos/pmd
Merge branch 'pr-1640'
This commit is contained in:
@ -21,6 +21,8 @@ This is a {{ site.pmd.release_type }} release.
|
||||
* java-codestyle
|
||||
* [#1543](https://github.com/pmd/pmd/issues/1543): \[java] LinguisticNaming should ignore overriden methods
|
||||
* [#1547](https://github.com/pmd/pmd/issues/1547): \[java] AtLeastOneConstructorRule: false-positive with lombok.AllArgsConstructor
|
||||
* java-design
|
||||
* [#1641](https://github.com/pmd/pmd/issues/1641): \[java] False-positive with Lombok and inner classes
|
||||
* java-errorprone
|
||||
* [#780](https://github.com/pmd/pmd/issues/780): \[java] BeanMembersShouldSerializeRule does not recognize lombok accessors
|
||||
* java-multithreading
|
||||
@ -35,6 +37,7 @@ This is a {{ site.pmd.release_type }} release.
|
||||
* [#1628](https://github.com/pmd/pmd/pull/1628): \[java] LinguisticNaming should ignore overriden methods - [Shubham](https://github.com/Shubham-2k17)
|
||||
* [#1634](https://github.com/pmd/pmd/pull/1634): \[java] BeanMembersShouldSerializeRule does not recognize lombok accessors - [Shubham](https://github.com/Shubham-2k17)
|
||||
* [#1635](https://github.com/pmd/pmd/pull/1635): \[java] UnsynchronizedStaticFormatter reports commons lang FastDateFormat - [Shubham](https://github.com/Shubham-2k17)
|
||||
* [#1640](https://github.com/pmd/pmd/pull/1640): \[java] Update instead of override classHasLombokAnnotation flag - [Phokham Nonava](https://github.com/fluxroot)
|
||||
|
||||
{% endtocmaker %}
|
||||
|
||||
|
@ -65,21 +65,27 @@ public class AbstractLombokAwareRule extends AbstractIgnoredAnnotationRule {
|
||||
|
||||
@Override
|
||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||
boolean oldValue = classHasLombokAnnotation;
|
||||
classHasLombokAnnotation = hasLombokAnnotation(node);
|
||||
return super.visit(node, data);
|
||||
Object result = super.visit(node, data);
|
||||
classHasLombokAnnotation = oldValue;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTEnumDeclaration node, Object data) {
|
||||
boolean oldValue = classHasLombokAnnotation;
|
||||
classHasLombokAnnotation = hasLombokAnnotation(node);
|
||||
return super.visit(node, data);
|
||||
Object result = super.visit(node, data);
|
||||
classHasLombokAnnotation = oldValue;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether there have been class level Lombok annotations found.
|
||||
* Note: this can only be queried after the class declaration node has been
|
||||
* processed.
|
||||
*
|
||||
*
|
||||
* @return <code>true</code> if a lombok annotation at the class level has
|
||||
* been found
|
||||
*/
|
||||
|
@ -55,7 +55,7 @@ public class ImmutableFieldRule extends AbstractLombokAwareRule {
|
||||
AccessNode accessNodeParent = field.getAccessNodeParent();
|
||||
if (accessNodeParent.isStatic() || !accessNodeParent.isPrivate() || accessNodeParent.isFinal()
|
||||
|| accessNodeParent.isVolatile()
|
||||
|| hasClassLombokAnnotation()
|
||||
|| hasLombokAnnotation(node)
|
||||
|| hasIgnoredAnnotation((Annotatable) accessNodeParent)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -573,6 +573,47 @@ public class MyClass {
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>[java] SingularField: Lombok false positive with inner class and annotated outer class</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Outer {
|
||||
public class Inner {
|
||||
private String innerField;
|
||||
}
|
||||
|
||||
private String outerField;
|
||||
|
||||
public Outer(String outerField) {
|
||||
this.outerField = outerField;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>[java] SingularField: Lombok false positive with annotated inner class</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
import lombok.Data;
|
||||
|
||||
public class Outer {
|
||||
@Data
|
||||
public class Inner {
|
||||
private String innerField;
|
||||
}
|
||||
|
||||
private String outerField;
|
||||
|
||||
public Outer(String outerField) {
|
||||
this.outerField = outerField;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#177 [java] SingularField with lambdas as final fields</description>
|
||||
|
Reference in New Issue
Block a user