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] UncommentedEmptyConstructor FP when constructor annotated with @Autowired #4141

Closed
LynnBroe opened this issue Oct 5, 2022 · 0 comments · Fixed by #4142
Closed

[java] UncommentedEmptyConstructor FP when constructor annotated with @Autowired #4141

LynnBroe opened this issue Oct 5, 2022 · 0 comments · Fixed by #4142
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@LynnBroe
Copy link
Contributor

LynnBroe commented Oct 5, 2022

Affects PMD Version:6.50.0

Rule:UncommentedEmptyConstructor

https://pmd.github.io/latest/pmd_rules_java_documentation.html#uncommentedemptyconstructor

Description:

Hi, I think PMD should not report a warning at line 5 when the constructor is annotated with @Autowired, this rule should consider annotation @Autowired. Besides, I find a previous issue is related to this problem, and it has been fixed. Thanks.

Code Sample demonstrating the issue:

import org.springframework.beans.factory.annotation.Autowired;

public class Bug {
    @Autowired
    public Bug() {
    }
}

Expected outcome:

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

Running PMD through: CLI

@LynnBroe LynnBroe added the a:false-positive PMD flags a piece of code that is not problematic label Oct 5, 2022
@adangel adangel changed the title UncommentedEmptyConstructor FP when annotated constructor with @Autowired [java] UncommentedEmptyConstructor FP when constructor annotated with @Autowired Oct 6, 2022
@adangel adangel added this to the 6.51.0 milestone Oct 6, 2022
adangel added a commit to adangel/pmd that referenced this issue Oct 6, 2022
adangel added a commit to adangel/pmd that referenced this issue Oct 6, 2022
[java] fix pmd#4141 Update UncommentedEmptyConstructor - ignore @Autowired annotations pmd#4142
@adangel adangel closed this as completed in a1bcad2 Oct 6, 2022
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