forked from phoedos/pmd
Merge branch 'master' into 7.0.x
This commit is contained in:
commit
7be569fa8b
@ -21,9 +21,15 @@ This is a {{ site.pmd.release_type }} release.
|
||||
|
||||
### Fixed Issues
|
||||
|
||||
* pmd-java
|
||||
* [#2708](https://github.com/pmd/pmd/pull/2708): \[java] False positive FinalFieldCouldBeStatic when using lombok Builder.Default
|
||||
|
||||
|
||||
### API Changes
|
||||
|
||||
### 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 %}
|
||||
|
||||
|
@ -723,8 +723,11 @@ in each object at runtime.
|
||||
<![CDATA[
|
||||
//FieldDeclaration
|
||||
[@Final= true() and @Static= false()]
|
||||
/VariableDeclarator/VariableInitializer/Expression
|
||||
/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal
|
||||
[not(preceding-sibling::Annotation/MarkerAnnotation/Name[@Image="Builder.Default"]
|
||||
and //ImportDeclaration/Name[@Image="lombok.Builder"])]
|
||||
/VariableDeclarator
|
||||
[VariableInitializer/Expression/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal]
|
||||
/VariableDeclaratorId
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<test-data
|
||||
xmlns="http://pmd.sourceforge.net/rule-tests"
|
||||
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">
|
||||
xmlns="http://pmd.sourceforge.net/rule-tests"
|
||||
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">
|
||||
|
||||
<test-code>
|
||||
<description>simple failure case</description>
|
||||
@ -98,6 +98,57 @@ interface Test {
|
||||
<code><![CDATA[
|
||||
public @interface MetricType {
|
||||
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>
|
||||
</test-code>
|
||||
|
4
pom.xml
4
pom.xml
@ -415,12 +415,12 @@
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd-core</artifactId>
|
||||
<version>6.26.0</version>
|
||||
<version>6.27.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd-java</artifactId>
|
||||
<version>6.26.0</version>
|
||||
<version>6.27.0</version>
|
||||
</dependency>
|
||||
<!-- This contains the dogfood ruleset -->
|
||||
<dependency>
|
||||
|
Loading…
x
Reference in New Issue
Block a user