Merge pull request #4193 from adangel:issue-4189-AbstractClassWithoutAnyMethod
[java] AbstractClassWithoutAnyMethod - exclude lombok constructor annotations #4193
This commit is contained in:
3 files changed
+35
-1
No files matched your search
@@ -34,6 +34,7 @@ This is a {{ site.pmd.release_type }} release.
|
||||
* [#4201](https://github.com/pmd/pmd/issues/4201): \[java] CommentDefaultAccessModifier should consider lombok's @<!-- -->Value
|
||||
* java-design
|
||||
* [#4188](https://github.com/pmd/pmd/issues/4188): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal false positive with Lombok's @<!-- -->NoArgsConstructor
|
||||
* [#4189](https://github.com/pmd/pmd/issues/4189): \[java] AbstractClassWithoutAnyMethod should consider lombok's @<!-- -->AllArgsConstructor
|
||||
* [#4200](https://github.com/pmd/pmd/issues/4200): \[java] ClassWithOnlyPrivateConstructorsShouldBeFinal should consider lombok's @<!-- -->Value
|
||||
* java-errorprone
|
||||
* [#4185](https://github.com/pmd/pmd/issues/4185): \[java] InvalidLogMessageFormat rule produces a NPE
|
||||
|
||||
@@ -31,7 +31,12 @@ protected constructor in order to prevent instantiation than make the class misl
|
||||
[@Abstract = true()]
|
||||
[not(./ClassOrInterfaceBody/*/ConstructorDeclaration)]
|
||||
[not(./ClassOrInterfaceBody/*/MethodDeclaration)]
|
||||
[not(../Annotation/MarkerAnnotation/Name[pmd-java:typeIs('com.google.auto.value.AutoValue')])]
|
||||
[not(../Annotation[pmd-java:typeIs('com.google.auto.value.AutoValue')
|
||||
or pmd-java:typeIs('lombok.AllArgsConstructor')
|
||||
or pmd-java:typeIs('lombok.NoArgsConstructor')
|
||||
or pmd-java:typeIs('lombok.RequiredArgsConstructor')
|
||||
]
|
||||
)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
||||
+28
@@ -102,4 +102,32 @@ class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>[java] AbstractClassWithoutAnyMethod should consider lombok's @AllArgsConstructor #4189</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
abstract class AllArgs {
|
||||
private String field;
|
||||
public int otherField;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
abstract class NoArgs {
|
||||
private String field;
|
||||
public int otherField;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
abstract class RequiredArgs {
|
||||
private String field;
|
||||
public int otherField;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
Reference in new issue
Block a user