Skip to content

Issue #11939: New filter SuppressWithNearbyTextFilter#12151

Merged
nrmancuso merged 2 commits into
checkstyle:masterfrom
stoyanK7:issue/11939-new-filter-SuppressWithNearbyPlainTextCommentFilter
Apr 26, 2023
Merged

Issue #11939: New filter SuppressWithNearbyTextFilter#12151
nrmancuso merged 2 commits into
checkstyle:masterfrom
stoyanK7:issue/11939-new-filter-SuppressWithNearbyPlainTextCommentFilter

Conversation

@stoyanK7

@stoyanK7 stoyanK7 commented Sep 1, 2022

Copy link
Copy Markdown
Collaborator

@stoyanK7

stoyanK7 commented Sep 1, 2022

Copy link
Copy Markdown
Collaborator Author

Github, generate site

@github-actions

github-actions Bot commented Sep 1, 2022

Copy link
Copy Markdown
Contributor

Site generation job failed on phase "parse_pr_info", step "React with rocket on run".
Link: https://github.com/checkstyle/checkstyle/actions/runs/2974139316

@github-actions

github-actions Bot commented Sep 1, 2022

Copy link
Copy Markdown
Contributor

Comment thread config/checkstyle_checks.xml Outdated
@stoyanK7 stoyanK7 marked this pull request as draft September 2, 2022 09:07
@stoyanK7 stoyanK7 marked this pull request as ready for review September 4, 2022 10:49
@stoyanK7

stoyanK7 commented Sep 4, 2022

Copy link
Copy Markdown
Collaborator Author

@nrmancuso I think the failing check is not related to my changes, right?

@nrmancuso

nrmancuso commented Sep 4, 2022

Copy link
Copy Markdown
Contributor

@stoyanK7 thanks for bringing this to my attention, inspections failure is not from your changes. I have changed some settings and restarted IDEA inspections. In the future, please put a link to failing build (and maybe snippet of output) in your comment, it will help us to easily help you from mobile.

@stoyanK7

stoyanK7 commented Sep 5, 2022

Copy link
Copy Markdown
Collaborator Author

@romani ping

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items:

Comment thread .ci/checkchmod.sh Outdated
Comment thread config/checkstyle_resources_suppressions.xml Outdated

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Items

Comment thread config/checkstyle_checks.xml Outdated
Comment thread src/main/resources/google_checks.xml Outdated
@stoyanK7 stoyanK7 changed the title Issue #11939: New filter SuppressWithNearbyPlainTextCommentFilter Issue #11939: New filter SuppressWithNearbyTextFilter Sep 9, 2022

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Items

Comment thread config/checkstyle_checks.xml Outdated
Comment thread config/checkstyle_checks.xml Outdated

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items:

Comment thread config/checkstyle_checks.xml Outdated
@romani

romani commented Sep 11, 2022

Copy link
Copy Markdown
Member

Github, generate web site.

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items:

Comment thread src/xdocs/config_filters.xml Outdated
Comment thread src/xdocs/config_filters.xml Outdated
@stoyanK7

Copy link
Copy Markdown
Collaborator Author

Github, generate site

@github-actions

Copy link
Copy Markdown
Contributor

@stoyanK7

Copy link
Copy Markdown
Collaborator Author

@romani is it currently possible we get some traction on this? I am keen on finishing it :)

@romani

romani commented Sep 21, 2022

Copy link
Copy Markdown
Member

Sorry for being slow... You in visible top of my to do list.

@romani

romani commented Sep 23, 2022

Copy link
Copy Markdown
Member

@rnveach , please help to review this PR while I am focusing on yours

@rnveach rnveach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, Checker is failing the CI. Please make it so CI is green.

Comment thread .ci/pitest-suppressions/pitest-filters-suppressions.xml Outdated
Comment thread src/xdocs/config_filters.xml Outdated
</section>

<section name="SuppressWithNearbyTextFilter">
<p>Since Checkstyle 10.3.4</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we had a release, this version and others in this PR needs to be updated.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be updated again.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this for the end.

* &lt;module name=&quot;Checker&quot;&gt;
* &lt;module name=&quot;SuppressWithNearbyTextFilter&quot;&gt;
* &lt;property name=&quot;checkPattern&quot; value=&quot;LineLengthCheck&quot;/&gt;
* &lt;/module&gt;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show me this example in action through the CLI?
To me it looks like you must specify commentFormat as it still has SUPPRESS CHECKSTYLE, also I see other issues with this example.

Another question is, why are we using all Java examples for this? This check is built for other file types since it has no connection to the Java AST. I fine with 1 or 2 Java examples, but there should be more that are non Java and show the user how to configure them.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fine with 1 or 2 Java examples, but there should be more that are non Java and show the user how to configure them

Valid point, don't know what I was thinking when writing those examples. Will switch them up a bit. Probably with something from the tests but simplified.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you point it out, nearbyTextPattern needs to be set to .* for this to work. This example is completely messed up. It is the second line that should have violation, ugh. I will go trough them carefully now.

stoyan@ZenBook:~/Desktop/checkstyle$ cat config.xml 
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
          "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
  <module name="SuppressWithNearbyTextFilter">
    <property name="checkPattern" value="LineLengthCheck"/>
    <property name="nearbyTextPattern" value=".*"/>
  </module>
  <module name="LineLength">
    <property name="max" value="40"/>
  </module>
  <module name="TreeWalker">
    <module name="ConstantName"/>
  </module>
</module>
stoyan@ZenBook:~/Desktop/checkstyle$ cat Test.java 
public final class Test {
static final int UPPER_CASE_CONSTANT1234567;
static final int lowerCaseConstant3;
static final int UPPER_CASE_CONSTANT4567891011;
}
stoyan@ZenBook:~/Desktop/checkstyle$ java -jar /media/stoyan/Elements/Open\ Source/checkstyle/target/checkstyle-10.3.5-SNAPSHOT-all.jar -c config.xml Test.java 
Starting audit...
[ERROR] /home/stoyan/Desktop/checkstyle/Test.java:3:18: Name 'lowerCaseConstant3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'. [ConstantName]
Audit done.
Checkstyle ends with 1 errors.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Fixed examples and added SQL, XML ones.

@romani

romani commented Apr 1, 2023

Copy link
Copy Markdown
Member

What needs to be done for failing CI?

I am not sure how to fix our CI execution.
It works to validate version to be same as in pom, in pom it is 10.9.4. but we will update it to 10.10.0 after a mere, as this is new module, so we bump second digit, there will be CI failures at GitHub action on release notes. We can not bump pom to 10.10.0 as we confident in version only based on merged changes.

Did we run any regression reports? I am not seeing a link to one.

Please suggest how to do this, it is filter. Both config and code should be updated to make it as diff.

@rnveach

rnveach commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

I recommend to create an issue to disable the ci item until after the work is merged if we will not create a fix before it is merged. We are not suppose to merge on a red ci.

For regression, just run a no harm with the filter on a random check. Before is only the check, after is check and filter. Just looking for issues or exceptions. I recommend suppression text be something simple and common that people would use like"ignore this".

@romani

romani commented Apr 1, 2023

Copy link
Copy Markdown
Member

We need to have shell version of code that bump second digit at

CS_RELEASE_VERSION=$(echo "$CS_POM_VERSION" | cut -d '-' -f 1)
and make third digit as 0, and only if pom version is not finished on ".0"

@romani

romani commented Apr 1, 2023

Copy link
Copy Markdown
Member

@rnveach , check-since-version is fixed in separate commit of this PR.
execution on my local:

New Check file: src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilter.java
New Check detected: src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilter.java
CS Release version: 10.9.4
Next release version is bug fix '10.9.4', we will bump second digit in it
Expected CS Release version after merge of target commit: 10.10.0
Grep for @since 10.10.0
 * @since 10.10.0

@romani

romani commented Apr 1, 2023

Copy link
Copy Markdown
Member

@stoyanK7 , I pushed in your branch, before working on it, please pull from stratch from remote.
please provide regression report as @rnveach suggested.

@rnveach , please continue review, we just need to know that code is ok and you need only report.
After you, we need review from @nrmancuso.

@rnveach

rnveach commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

My review is done until regression report is provided.

@stoyanK7

stoyanK7 commented Apr 1, 2023

Copy link
Copy Markdown
Collaborator Author

Github, generate report

@github-actions

github-actions Bot commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

@romani

romani commented Apr 1, 2023

Copy link
Copy Markdown
Member

@rnveach , report looks good

@rnveach

rnveach commented Apr 3, 2023

Copy link
Copy Markdown
Contributor

@stoyanK7 CI is failing. Is pitest fix now going to be in this PR?

@stoyanK7

stoyanK7 commented Apr 3, 2023

Copy link
Copy Markdown
Collaborator Author

@rnveach No, I will move it to a separate issue. Please proceed with the review.

@romani

romani commented Apr 3, 2023

Copy link
Copy Markdown
Member

@stoyanK7 , please restore commit stoyanK7@eb46596 CI must be green to merge

@rnveach rnveach assigned nrmancuso and unassigned rnveach Apr 3, 2023
@nrmancuso

Copy link
Copy Markdown
Contributor

Github, generate site

@github-actions

Copy link
Copy Markdown
Contributor

Site generation job failed on phase "generate_site",
step "Set output".
Link: https://github.com/checkstyle/checkstyle/actions/runs/4657917161

@stoyanK7

Copy link
Copy Markdown
Collaborator Author

Github, generate site

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Items:

@stoyanK7

Copy link
Copy Markdown
Collaborator Author

Github, generate site

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this

@nrmancuso nrmancuso merged commit a0df847 into checkstyle:master Apr 26, 2023
@stoyanK7 stoyanK7 deleted the issue/11939-new-filter-SuppressWithNearbyPlainTextCommentFilter branch April 26, 2023 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New filter: SuppressWithNearbyTextFilter to suppress checks with inline comments in any file type

4 participants