Skip to content

Change LineLength Check parent from TreeWalker to Checker #2116

@rnveach

Description

@rnveach

Why does LineLengthCheck need the java parser to work?
It could be be based on AbstractFileSetCheck and allow any file type to use this check, like property and xml files.

It returns nothing for acceptable/required/default TokenTypes.
The first thing it does is get all the lines of the file, which "processFiltered" will pass it.
It never visits anything or use any of the ASTs.
Only downside is that it would have to move out of the TreeWalker module in the configs.

ATTENTION: Migration Notes

Move LineLengthCheck outside of TreeWalker and place it directly in Checker.

By default, the changes to the check will scan all files not just Java files. If you want to restore the original behavior, using the following configuration with the fileExtensions property.

<module name="LineLengthCheck">
  <property name="fileExtensions" value="java" />
</module>

If there was some suppression in code by SuppressWithNearbyCommentFilter with influenceFormat ... unfortunately there is no similar filter of Checker, the only filter in Checker:

    <module name="SuppressWithPlainTextCommentFilter">
        <property name="offCommentFormat" value="CHECKSTYLE OFF\: ([\w\|]+)"/>
        <property name="onCommentFormat" value="CHECKSTYLE ON\: ([\w\|]+)"/>
        <property name="checkFormat" value="$1"/>
    </module>

see example of migration: https://github.com/checkstyle/equalsverifier/commit/bce5a001b202a46978723572e325214bf5b14270

After implementation of #7064, suppression should be possible by SuppressWithPlainTextCommentFilter.

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