Trigger for non lombok Builder.Default

This commit is contained in:
Ollie Abbey
2020-08-27 08:45:53 +01:00
parent cd98a36b66
commit 363c3a30ff
2 changed files with 22 additions and 2 deletions

View File

@ -742,7 +742,8 @@ in each object at runtime.
[@Final= true() and @Static= false()]
[VariableDeclarator/VariableInitializer/Expression
/PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix/Literal]
[not(preceding-sibling::Annotation/MarkerAnnotation/Name[@Image="Builder.Default"])]
[not(preceding-sibling::Annotation/MarkerAnnotation/Name[@Image="Builder.Default"]
and //ImportDeclaration/Name[@Image="lombok.Builder"])]
]]>
</value>
</property>

View File

@ -103,7 +103,7 @@ public @interface MetricType {
</test-code>
<test-code>
<description>#2708 - False positive with @Builder.Default fields</description>
<description>#2708 - False positive with lombok @Builder.Default fields</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
package com.example;
@ -111,6 +111,25 @@ 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 {