Skip to content

Regexp check for unnecessary // ok comments is configured under TreeWalker #19993

@smita1078

Description

@smita1078

Description

While working on #19983 , we noticed that plain // ok comments are currently not reporting violations even though there is an UnnecessaryOkComment regexp check configured.

Current configuration:

<module name="TreeWalker">
    ...
    <module name="Regexp">
      <property name="id" value="UnnecessaryOkComment"/>
      <property name="format"
               value="(?i)\/\/\s*ok$"/>
      <property name="illegalPattern" value="true"/>
      <message key="illegal.regexp"
               value="'// ok' comments should have an explanation, or they are unnecessary."/>
    </module>
</module>

However, Regexp is a Checker-level module and not a TreeWalker module.

Because of this, the check does not appear to be applied, which is why existing plain // ok comments in input files (for example some ParenPad inputs) are currently not producing violations.

Expected Behavior

Plain comments like:

// ok

should report violations according to the configured regexp.

Proposed Fix

Move the Regexp module from under TreeWalker to the Checker level configuration so it is properly applied repository-wide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions