-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[java] CommentDefaultAccessModifier comment needs to be before annotation if present #4578
Copy link
Copy link
Closed
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematic
Milestone
Description
Affects PMD Version: 7.0.0-rc2
Rule: CommentDefaultAccessModifier
Description:
Code Sample demonstrating the issue:
@SuppressWarnings("")
/* package */ void test1() {
System.out.println("This triggers CommentDefaultAccessModifier");
}
/* package */ @SuppressWarnings("")
void test2() {
System.out.println("This does not trigger CommentDefaultAccessModifier");
}Expected outcome:
(I'm not sure if this is intended, and it's probably a matter of opinion.)
- In
test1above, where the comment meant to represent a package modifier is after the annotation on that method, aCommentDefaultAccessModifierrule violation is flagged up. - This is not the case in
test2, where that comment is before the annotation.
Since /* package */ seems to be intended to replace a public/private/protected modifier that doesn't exist for default access, it feels it would fit more naturally where those modifiers would be, i.e. between the annotations and the return type (as in test1).
However, this is currently flagged as a CommentDefaultAccessModifier rule violation.
Running PMD through: Maven (using maven-pmd-plugin version 3.20.1-pmd-7-SNAPSHOT configured with PMD 7.0.0-rc2)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematic