From #11884
Description
The filter should work exactly like SuppressWithNearbyCommentFilter. The only difference is that it should be able to filter different file types(i.e. have Checker as parent module instead of TreeWalker) - java, xml, js, properties, sql, etc. It shoud have the following properties:
| Name |
Description |
Default value |
commentFormat |
Specify comment pattern to trigger filter to begin suppression. |
"SUPPRESS CHECKSTYLE (\w+)" |
checkFormat |
Specify check pattern to suppress. |
".*" |
messageFormat |
Define message pattern to suppress. |
null |
idFormat |
Specify check ID pattern to suppress. |
null |
influenceFormat |
Specify negative/zero/positive value that defines the number of lines preceding/at/following the suppression comment. |
"0" |
How it should work
This is just an example config with 3 files to show what is expected. Configuration of properties should be the same as the above mentioned filter. Their behaviour is well-documented there.
Config
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="NewFilter"/>
<module name="LineLength">
<property name="max" value="2"/>
</module>
</module>
XML
<something/> <!-- SUPPRESS CHECKSTYLE LineLengthCheck --> // ok
<somethingelse/> // violation
Expected output
$ java -jar checkstyle-all.jar -c config.xml file.xml
[ERROR] file.xml:3:0: Line is longer than 2 characters (found 16). [LineLength]
SQL
SELECT COUNT(1) FROM filters; -- SUPPRESS CHECKSTYLE LineLengthCheck // ok
SELECT COUNT(1) FROM checks; // violation
Expected output
$ java -jar checkstyle-all.jar -c config.xml file.sql
[ERROR] file.sql:2:0: Line is longer than 2 characters (found 28). [LineLength]
Java
int a = 5; // SUPPRESS CHECKSTYLE LineLengthCheck // ok
int b = 3; // violation
Expected output
$ java -jar checkstyle-all.jar -c config.xml file.java
[ERROR] file.java:2:0: Line is longer than 2 characters (found 10). [LineLength]
Config with influenceFormat
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="NewFilter">
<property name="influenceFormat" value="2"/>
</module>
<module name="LineLength">
<property name="max" value="2"/>
</module>
</module>
XML
<something/> <!-- SUPPRESS CHECKSTYLE LineLengthCheck --> // ok
<somethingelse/> // ok
<somethingelse1/> //ok
<somethingelse2/> // violation
An aggreement on name needs to be made. For the demo purpose I just called it NewFilter.
From #11884
Description
The filter should work exactly like SuppressWithNearbyCommentFilter. The only difference is that it should be able to filter different file types(i.e. have
Checkeras parent module instead ofTreeWalker) -java,xml,js,properties,sql, etc. It shoud have the following properties:commentFormatcheckFormatmessageFormatidFormatinfluenceFormatHow it should work
This is just an example config with 3 files to show what is expected. Configuration of properties should be the same as the above mentioned filter. Their behaviour is well-documented there.
Config
XML
Expected output
SQL
Expected output
Java
Expected output
Config with
influenceFormatXML
An aggreement on name needs to be made. For the demo purpose I just called it
NewFilter.