-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New filter: SuppressWithNearbyTextFilter to suppress checks with inline comments in any file type #11939
Comments
I guess I will roughly start working on this. |
please remove first line or put violation on it. please write example with influenceFormat can you suggest a name for new Filter ? |
Here are e few suggestions. Let me know what you think about them.
First two sound good, last one not so much. |
I think your new filter will be Checker version of https://checkstyle.org/config_filters.html#SuppressWithNearbyCommentFilter what about SuppressWithNearbyPlainTextCommentFilter? |
|
Just a thought: it would be great to allow <?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>
<something/> <!-- SUPPRESS CHECKSTYLE LineLengthCheck (2)--> // ok
<somethingelse/> // ok
<somethingelse1/> //ok
<somethingelse2/> // violation
<something/> <!-- SUPPRESS CHECKSTYLE LineLengthCheck (1)--> // ok
<somethingelse/> // ok
<somethingelse1/> // violation
<somethingelse2/> // violation
<something/> <!-- SUPPRESS CHECKSTYLE LineLengthCheck (3)--> // ok
<somethingelse/> // ok
<somethingelse1/> // ok
<somethingelse2/> // ok
|
<property name="commentFormat"
value="CHECKSTYLE IGNORE (\w+) FOR NEXT (\d+) LINES"/>
<property name="checkFormat" value="$1"/>
<property name="influenceFormat" value="$2"/> static final int lowerCaseConstant; // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 3 LINES
static final int lowerCaseConstant1;
static final int lowerCaseConstant2;
static final int lowerCaseConstant3;
static final int lowerCaseConstant4; // will warn here Taken from here(scroll a bit down to see example). Or do you expect your proposal to be possible as well? |
@stoyanK7 in your example above(in issue description) the check ID property is not in the config, which implies that this is now “baked in” to the default config for this filter. I was thinking that if we are making check ID capture group as the first capture group, we should do the same for influenceFormat as the second group. Or, was this just an omission? |
@nick-mancuso I'm sorry, I don't get what you meant here. Could you explain in other words? |
@stoyanK7 all will become clear in PR, let’s not worry about this now. |
@stoyanK7 I don't think your config example makes sense or is valid.
|
@rnveach This must have been a mistake, thanks for pointing it out. Fixing it right now. |
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 ofTreeWalker
) -java
,xml
,js
,properties
,sql
, etc. It shoud have the following properties:commentFormat
checkFormat
messageFormat
idFormat
influenceFormat
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
Expected output
SQL
Expected output
Java
Expected output
Config with
influenceFormat
XML
An aggreement on name needs to be made. For the demo purpose I just called it
NewFilter
.The text was updated successfully, but these errors were encountered: