Skip to content

SuppressWithPlainTextCommentFilter is slow on files with multiple errors #8807

@basinilya

Description

@basinilya

Check documentation: https://checkstyle.org/config_filters.html#SuppressWithPlainTextCommentFilter

> javac BigJava.java
>

> type ..\checkstyle\checkstyle.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
    This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
    Checkstyle-Configuration: project-local
    Description: none
-->
<module name="Checker">
  <property name="severity" value="warning"/>
  <module name="TreeWalker">
  </module>
  <module name="LineLength">
    <property name="severity" value="warning"/>
    <property name="max" value="120"/>
    <property name="fileExtensions" value="java" />
  </module>
  <module name="SuppressWithPlainTextCommentFilter">
    <property name="offCommentFormat" value="CHECKSTYLE\.OFF\: ([\w\|]+)"/>
    <property name="onCommentFormat" value="CHECKSTYLE\.ON\: ([\w\|]+)"/>
    <property name="checkFormat" value="$1"/>
  </module>
</module>


> type BigJava.java
public interface BigJava {
    int XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0 = 0;
... full file attached
    int XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2999 = 0;
}


> set "RUN_LOCALE=-Duser.language=en -Duser.country=US"
> java %RUN_LOCALE% -jar checkstyle-8.36-all.jar -c config.xml BigJava.java
Starting audit...
[WARN] C:\11\eclipse-cs-254-bad\src\BigJava.java:3: Line is longer than 120 characters (found 134). [LineLength]
...
[WARN] C:\11\eclipse-cs-254-bad\src\BigJava.java:3002: Line is longer than 120 characters (found 137). [LineLength]
Audit done.

I expect the command above to run in roughly 2 seconds on a mobile 2GHz i7. However, it takes not less than 16 seconds. It becomes a pain when my IDE waits for the checkstyle plugin during the full build.

The filter SuppressWithPlainTextCommentFilter re-reads the file from disk on each error instead of reading it just one time.

I'm willing to create a pull request that will add caching to the filter.


BigJava.java.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions