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
Issue #13553: False positive in FallThroughCheck on last case #14734
base: master
Are you sure you want to change the base?
Issue #13553: False positive in FallThroughCheck on last case #14734
Conversation
06a1b46
to
8a0a354
Compare
GitHub, generate report |
} | ||
} | ||
|
||
return hasReliefComment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor hasReliefComment
the warning or on the same line before the {@code case}(ugly, but possible). | ||
The comment containing these words must be on the last non-empty line | ||
before the {@code case} triggering the warning or on the same line before | ||
the {@code case}(ugly, but possible). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the sentence in the doc as required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update in doc to remove:
The comment containing these words must be all on one line
I don't remember this conversation regarding this but does this mean if I have a suppression word as "suppress me", it will match things like "suppress \n me"? Do you have a test example showing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your updated documentation says:
...on the same line before the ...
How is that different then ...must be all on one line...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update in doc to remove:
The comment containing these words must be all on one line
I don't remember this conversation regarding this but does this mean if I have a suppression word as "suppress me", it will match things like "suppress \n me"? Do you have a test example showing this?
No, I don't think "suppress \n me" will match.
This is matching by the pattern
private Pattern reliefPattern = Pattern.compile("falls?[ -]?thr(u|ough)");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your updated documentation says:
...on the same line before the ...
How is that different then
...must be all on one line...
?
I didn't see the conversion about this part either, but I think "must be all on one line" is redundant and confusing. I don't really understand what it means. The subject of this sentence is "the comment containing these words". However, we only need one "comment" containing these words to suppress this check for that branch.
If we remove this "must be all on one line.", and updated it to
The comment containing these words must be on the last non-empty line
before the {@code case} triggering the warning or on the same line before
the {@code case}(ugly, but possible).
I think this might be able to explain everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like comment in issue came from #12966 (comment) . This was about "the last comment on that line". This is why the issue has /* block */ /* fallthru */ // comment
.
If you agree, please restore original wording and add some wording that it can be any comment on that line.
Can you point to keywords where the suppression text is not the last comment on the line. If we don't have one, then create it and point to it.
Example:
/* trigger */ /* comment */ // last
/* comment */ /* fallthru */ // last
src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java
Show resolved
Hide resolved
@nrmancuso @romani please take a look. |
Rebasing on latest master, good to merge |
8a0a354
to
988b8b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to merge
src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheck.java
Show resolved
Hide resolved
Edit: I am removing this. Property is additive, not either/or. |
0d8f015
to
4b753cf
Compare
4b753cf
to
7e9dba3
Compare
GitHub, generate report |
Latest review discussion is at #14734 (comment) |
Fix for Issue #13553, Continue of #14016
Config
Regression Report
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/8a0a354_2024060435/reports/diff/checkstyle/index.html
5 violations are removed in Checkstyle code base. Differences in this report are intended.
For example:
checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough4.java
Line 109 in 4fe8118
This is no longer a violation in this case. Same for the other 4 cases.
Diff Regression config: https://gist.githubusercontent.com/Lmh-java/55bdd9e289522aff23374ad7b5571c2c/raw/4e52c69d3888eff5f976f0ae87c058e98c0dd72d/input-fall-thru-config.xml