[java] CommentRequired should ignore private static final field or Logger field

Open
#4,713 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
67/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
devtools

Research direction

Start with the CommentRequired rule documentation and its handling of fieldCommentRequirement, then reproduce the reported Java examples through the Maven Plugin. Check how private static final fields and Logger fields are classified, and add regression coverage showing that the requested fields are ignored while other required fields remain checked.

Written by the indexing model from the issue text.

Description

a:false-positive

Affects PMD Version:
6.55.0
7.0.0

Rule:

https://docs.pmd-code.org/latest/pmd_rules_java_documentation.html#commentrequired

Description:
CommentRequired checked block private static final field and Logger field.

Code Sample demonstrating the issue:

private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPaging.class);

private static final Integer maxLimitCount = 10;

Update Rule:

<rule ref="category/java/documentation.xml/CommentRequired">
    <properties>
        <property name="fieldCommentRequirement" value="Required" />
       <property name="privateStaticFinalNamedFieldIgnored" value="LOGGER|LOG|log" />
        <property name="privateStaticFinalField" value="Ignored" />
    </properties>
</rule>

Running PMD through: [Maven Plugin]

Dominant language
Java
Stars
5.5k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
54

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pmd/pmd

All issues in pmd/pmd

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.