@ -16,9 +16,15 @@ This is a {{ site.pmd.release_type }} release.
|
|||||||
|
|
||||||
### Fixed Issues
|
### Fixed Issues
|
||||||
|
|
||||||
|
* pmd-java
|
||||||
|
* [#2708](https://github.com/pmd/pmd/pull/2708): \[java] False positive FinalFieldCouldBeStatic when using lombok Builder.Default
|
||||||
|
|
||||||
|
|
||||||
### API Changes
|
### API Changes
|
||||||
|
|
||||||
### External Contributions
|
### External Contributions
|
||||||
|
|
||||||
|
* [#2747](https://github.com/pmd/pmd/pull/2747): \[java] Don't trigger FinalFieldCouldBeStatic when field is annotated with lombok @Builder.Default - [Ollie Abbey](https://github.com/ollieabbey)
|
||||||
|
|
||||||
{% endtocmaker %}
|
{% endtocmaker %}
|
||||||
|
|
||||||
|
@ -740,8 +740,11 @@ in each object at runtime.
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
//FieldDeclaration
|
//FieldDeclaration
|
||||||
[@Final= true() and @Static= false()]
|
[@Final= true() and @Static= false()]
|
||||||
/VariableDeclarator/VariableInitializer/Expression
|
[not(preceding-sibling::Annotation/MarkerAnnotation/Name[@Image="Builder.Default"]
|
||||||
/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal
|
and //ImportDeclaration/Name[@Image="lombok.Builder"])]
|
||||||
|
/VariableDeclarator
|
||||||
|
[VariableInitializer/Expression/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal]
|
||||||
|
/VariableDeclaratorId
|
||||||
]]>
|
]]>
|
||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<test-data
|
<test-data
|
||||||
xmlns="http://pmd.sourceforge.net/rule-tests"
|
xmlns="http://pmd.sourceforge.net/rule-tests"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
|
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
|
||||||
|
|
||||||
<test-code>
|
<test-code>
|
||||||
<description>simple failure case</description>
|
<description>simple failure case</description>
|
||||||
@ -98,6 +98,57 @@ interface Test {
|
|||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
public @interface MetricType {
|
public @interface MetricType {
|
||||||
int CHECKBOX = 0, COUNTER = 1, SPINNER = 2, NOTE = 3, STOPWATCH = 4, HEADER = 5;
|
int CHECKBOX = 0, COUNTER = 1, SPINNER = 2, NOTE = 3, STOPWATCH = 4, HEADER = 5;
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>#2708 - False positive with lombok @Builder.Default fields</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class ExampleClass {
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private final long exampleField = 0L;
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>#2708 - Should trigger with non-lombok @Builder.Default fields</description>
|
||||||
|
<expected-problems>1</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import not.lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class ExampleClass {
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private final long exampleField = 0L;
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>Should trigger multiple times for fields declared on one line</description>
|
||||||
|
<expected-problems>2</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
public class ExampleClass {
|
||||||
|
|
||||||
|
private final String one = "one", two = "two";
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
Reference in New Issue
Block a user