A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1641 below:

[java] False-positive with Lombok and inner classes · Issue #1641 · pmd/pmd · GitHub

Affects PMD Version:

Rule:
SingularFieldRule

Description:
We encountered a false positive using the SingularFieldRule in combination with Lombok.

In our Lombok annotated (@Data) class we use an inner class before a field. PMD incorrectly alerts with the SingularFieldRule for this field. Instead PMD should see the Lombok annotation on the outer class and should skip executing this rule.

If we move the inner class to the end of the outer class, everything is fine and the rule passes.

Code Sample demonstrating the issue:

import lombok.Data;

@Data
public class MyClass {
	public enum InnerEnum {
		ONE, TWO
	}

	private String field1;

	public MyClass(String field1) {
		this.field1 = field1;
	}
}

Running PMD through: Gradle (but does not matter)

I have created a fix in PR #1640. PMD should only update not override classHasLombokAnnotation.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4