KEMBAR78
Annotation location rule is not enforced in package-info.java file · Issue #17540 · checkstyle/checkstyle · GitHub
Skip to content

Annotation location rule is not enforced in package-info.java file #17540

@mohitsatr

Description

@mohitsatr

I have read check documentation: https://checkstyle.org/checks/annotationlocation.html
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

CODE:

/** This is a package. */
@Deprecated @CheckReturnValue
package com.google.checkstyle.test.chapter4formatting.rule4852classannotations;
// EXPECTED VIOLATION ABOVE

CLI:

$ java -jar checkstyle-10.26.1-all.jar -c google_checks.xml example1/package-info.java
Starting audit...
Audit done.

FORMATTER:

$ diff -Naru example1/package-info.java FormattedCode.java 
- - -  example1/package-info.java 2025-08-04 12:43:05.080476900 +0530
+++ FormattedCode.java  2025-08-04 12:55:47.703361100 +0530
@@ -1,4 +1,5 @@
 /** This is a package. */
-@Deprecated @CheckReturnValue
+@Deprecated
+@CheckReturnValue
 package com.google.checkstyle.test.chapter4formatting.rule4852classannotations;

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedbugfalse negativeissues where check should place violations on code, but does not

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions