checkstyle / checkstyle/checkstyle
violationBetweenAnnotationAndMethod and violationBetweenJavadocAndMethod miss comments that land outside MODIFIERS
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 4.2k
- Avg merge
- 22h 23m
- Merged PRs (30d)
- 232
Description
I have read check documentation: https://checkstyle.org/checks
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
```
/var/tmp $ cat config.xml
```
```
/var/tmp $ cat Foo.java
class Foo {
@Override
// violation above 'xxx'
void bar() {}
}
/var/tmp $ RUN_LOCALE="-Duser.langua/var/tmp $ java $RUN_LOCALE -jar checkstyle-10.25.0-all.jar -c config.xml Foo.java
Starting audit...Audit done.
```
### Describe what you expect in detail.
I expect a violation here this is #19757's own issue description
`(@Override → comment → void foo() {} `the check is supposed to catch. It doesn't.
### Root cause:
the query assumes a` // violation `comment placed after an annotation always lands as a child of MODIFIERS. So the check only works when the annotated declaration happens to have an explicit modifier keyword right after the annotation. Anything else bare methods, bare top-level types, and (found via #17172) module declarations silently passes.
Contributor guide
Research direction
Start by reading the issue’s example configuration and Java snippet, then inspect the MatchXpath check and the query’s handling of declaration comments outside MODIFIERS. The reported behavior should be reproduced with the supplied annotation/comment/method example and extended to the other listed declaration cases. Done means those comments are detected without breaking existing cases; the issue names no test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100