-
Notifications
You must be signed in to change notification settings - Fork 6
Issue #122: Support multiple instances of the same Checkstyle check #123
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
base: main
Are you sure you want to change the base?
Conversation
|
@romani @rdiachenko This PR currently covers most of the cases (all cases for sarif report) but there are some failing edge cases for xml report. Issue: XML reports only mention the check ID, which creates ambiguous matching when the ID value matches another check's class name, such as: <module name="Checker">
<module name="TreeWalker">
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck">
<property name="id" value="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck"/>
</module>
</module>
</module>No such issue with sarif since it mentions both the check name as well as the id. Can we make a similar thing for xml report in the main checkstyle repo otherwise there will be uncertainty with the logic always. |
|
@Anmol202005 please create an issue in the main checkstyle repo and include examples and expected output. Regarding: I think this is more theoretical than practical case. Users are in control of their configs, and I can't imagine the case when they want to set id pointing to a different module. This can be done by some odd refactoring or mistake. If the above case happens, what's the result of autofix execution? Will it fail or do nothing? We should just ignore such cases, because you have violation belonging to a different module id, which means if you try to execute recipe, nothing should change, right? |
|
If people wanted to shoot in their own leg by such config, ok , it is their problem. |
Yes nothing will change :) |
|
@romani this PR is ready to review. Should i create an issue for same in the main checkstyle repo ? |
|
Please create , but please use CLI to show a problem, to let us see all details. |
romani
left a comment
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.
we need some cleanup from "source" (xml attribute of checkstyle report) in naming to checkId or checkName or ...
as we have sarif report, so better to use better term that is not xml format special
| private final String severity; | ||
|
|
||
| private final CheckstyleCheck source; | ||
| private final String source; |
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.
can we rename "source" to "checkId" ?
I know xml attribute is "source", very bad name, very confusing, and now we copied it new project. Better to have better name that is logical and explain what is this.
| } | ||
|
|
||
| private CheckstyleViolation createViolation(CheckstyleCheck check, Result result) { | ||
| private CheckstyleViolation createViolation(String check, Result result) { |
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.
is first parameter checkId ?
| .findFirst(); | ||
| } | ||
|
|
||
| public static Optional<CheckstyleCheck> fromSourceExact(String source) { |
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.
rename parameter please.
Fixes: #122