Skip to content

[java] CommentSize: False positive with file header comments #6270

Closed

Description

@Vampire

Affects PMD Version: 7.18.0

Rule: CommentSize

Description:

The docs say that "non-header comments" are checked.
But the code checks all comments.
If you for example have the typical ASLv2 header comment, all your files will violate the rule with default settings as this is definitely a bit over 6 lines.

I guess this is not really hit by many people, as I probably most do similar to me and either disable the rule or set the max lines to 99999 to just check the max line length. :-)

Additionally from a cursory look, the implementation searches for the first and last non-empty lines and counts from first to last. If I did read that correctly, then the docs also need a correction as the bad example just has one line with that logic and thus would not violate the rule.

Expected outcome:

  • PMD reports a violation at line 1 but that's wrong. That's a false positive.
  • Documentation should show a correct bad example.

Running PMD through: Gradle

Activity

  1. added
    a:false-positive
    on Nov 26, 2025
  2. changed the title [-][java] `CommentSize` wrongly checks header comments[/-] [+][java] CommentSize: False positive with header comments[/+] on Jan 16, 2026
  3. added this to the 7.27.0 milestone on Aug 7, 2026
  4. added a commit that references this issue on Aug 7, 2026
    71f85f0
  5. changed the title [-][java] CommentSize: False positive with header comments[/-] [+][java] CommentSize: False positive with file header comments[/+] on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positive

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions