Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] ConstructorCallsOverridableMethod: false positive with lombok's @Value #4510

Closed
LynnBroe opened this issue Apr 27, 2023 · 0 comments · Fixed by #4542
Closed

[java] ConstructorCallsOverridableMethod: false positive with lombok's @Value #4510

LynnBroe opened this issue Apr 27, 2023 · 0 comments · Fixed by #4542
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@LynnBroe
Copy link
Contributor

Affects PMD Version:7.0.0-rc1

Rule: ConstructorCallsOverridableMethod

Please provide the rule name and a link to the rule documentation:
https://docs.pmd-code.org/latest/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod

Description:
The first code sample uses the annotation @Value which can make the class Foo1 final. So the analysis results of the two cases should be equivalent because these two cases are equivalent. However, PMD reports a warning in the first sample and no warnings in the second one because PMD ignores the annotation @Value. PMD should not report a warning in Case1 like the Case2.

Code Sample demonstrating the issue:
Case1

import lombok.Value;
@Value
class Foo1 {
    public Foo1(String bar) {
        bar();  //  report a warning
    }
    public void bar() {}
}

Case2

final class Foo2 {
    public Foo2(String bar) {
        bar();  //  report no warning
    }
    public void bar() {}
}

Expected outcome:

PMD reports a violation at line 5 in the first case, but that's wrong. That's a false positive.

@LynnBroe LynnBroe added the a:false-positive PMD flags a piece of code that is not problematic label Apr 27, 2023
@adangel adangel changed the title [java]A false positive about ConstructorCallsOverridableMethod and @Value [java] ConstructorCallsOverridableMethod: false positive with lombok's @Value May 28, 2023
@adangel adangel added this to the 7.0.0 milestone May 28, 2023
adangel added a commit to adangel/pmd that referenced this issue May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants