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 #14424: Add option to skip validation based on list of annotations #14701
base: master
Are you sure you want to change the base?
Issue #14424: Add option to skip validation based on list of annotations #14701
Conversation
8c907a3
to
f763b2e
Compare
GitHub, generate report |
GitHub, generate report |
@nrmancuso @romani Please take a look |
Github, generate site |
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.
only one minor:
...ain/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheck.java
Outdated
Show resolved
Hide resolved
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.
items:
...rces/com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor/Example2.java
Show resolved
Hide resolved
...rces/com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor/Example2.java
Outdated
Show resolved
Hide resolved
...rces/com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor/Example2.java
Outdated
Show resolved
Hide resolved
f763b2e
to
dfc82c6
Compare
@Lmh-java, please reply "done" to each review item, to give us clear singnal your arer ready for review and nothing is missed to be addressed. Do not resolve conversations, maintainers will do this as confirmation that is done as expected. |
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.
last minors:
src/xdocs/checks/design/hideutilityclassconstructor.xml.template
Outdated
Show resolved
Hide resolved
...rces/com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor/Example1.java
Outdated
Show resolved
Hide resolved
...ain/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheck.java
Outdated
Show resolved
Hide resolved
dfc82c6
to
80b09ce
Compare
@Lmh-java , please reply "done" to each review item, it help a lot. |
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.
last:
...ain/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheck.java
Outdated
Show resolved
Hide resolved
GitHub, generate website |
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.
items:
...rces/com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor/Example1.java
Outdated
Show resolved
Hide resolved
80b09ce
to
c52a701
Compare
Please reply "done" as confirmation that get best practice of PR review |
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.
This only shows regression. We need a report for the new property as well. Configure it for some annotation. You can use the annotation specified in the issue.
...ain/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheck.java
Outdated
Show resolved
Hide resolved
src/xdocs/checks/design/hideutilityclassconstructor.xml.template
Outdated
Show resolved
Hide resolved
122dfa9
to
75e5ab1
Compare
GitHub, generate report |
@rnveach https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/75e5ab1_2024052933/reports/diff/index.html I have to use a different project to test this new feature. I have gone through our default regression project list, but didn't see any valid test case satisfying all the conditions here. |
Report is fine, just that if original regression showed nothing for this change I would still leave the projects in there as proof they don't show anything. |
GitHub, generate report |
75e5ab1
to
6bcff74
Compare
Github, generate site |
GitHub, generate report |
@rnveach There are no existing projects in the default list with this test case. They are either not having any annotation, or they are already final class, or they contain some non-static method, etc. The only changes is in the one project I configured additionally. Some main classes with SpringBootApplication annotation are ignored. I think I messed up with the previous regression report. I have had one additional project of local-checkstyle in the project list by mistake. I noticed that we are not using |
It depends on where this local is coming from and if anything else is using it. If this is the same git repository provided to regression as the basis for checkstyle, then you have to know that part of the work regression does to do its magic is to switch branches in that git repository. It has to switch between master and the PR to install both versions of checkstyle in order to run them. That switching may cause issues with you defining it as a property to test on as it is only expecting to stay in master and not move around. This is an issue to be able to set up a way to do regression on the changes in the PR itself. |
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.
Last things on documentation.
<module name="TreeWalker"> | ||
<module name="HideUtilityClassConstructor"> | ||
<property name="ignoreAnnotatedBy" | ||
value="SpringBootApplication, java.lang.Deprecated" /> |
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.
Annotation names provided in this property must exactly match the annotation names on the classes. If the target class has annotations specified with their fully qualified names (including package), the annotations in this property should also be specified with their fully qualified names. Similarly, if the target class has annotations specified with their simple names, this property should contain the annotations with the same simple names.
Show some of these issues in your example.
I assume Deprecated
by itself won't work. Show that and put a comment to that effect.
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 you also provide me where we said we would be so strict?
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.
I assume Deprecated by itself won't work.
Only Deprecated
will not work if it doesn't match the annotation used.
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 you also provide me where we said we would be so strict?
We mentioned this at #14424 (comment). We agreed to do exact match first as #14553. We might do pattern matching later, but they need to solve the problem of #5434 first.
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.
yes, I am fine to be strict for first step, we can improve later if sombody start to complain.
We just need to document this.
<td>Ignore classes annotated with the specified annotation(s). Annotation names provided in this property must exactly match the annotation names on the classes. If the target class has annotations specified with their fully qualified names (including package), the annotations in this property should also be specified with their fully qualified names. Similarly, if the target class has annotations specified with their simple names, this property should contain the annotations with the same simple names.</td> | ||
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td> | ||
<td><code>{}</code></td> | ||
<td>10.16.0</td> |
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.
Version needs updated.
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.
should be 10.17.0
@Lmh-java , please help us to finish this PR, we are so close to merge state. |
6bcff74
to
4218a94
Compare
4218a94
to
70bd1b7
Compare
Sorry, I was quite occupied with other stuffs. I have updated a new example for #14701 (comment) and updated the version. |
GitHub, generate site |
Feature for Issue #14424
Diff Regression config: https://gist.githubusercontent.com/Lmh-java/814de3d973b95b957463eaab2c83f39b/raw/5f3e60d41571b0bff3e6f344af0f7e4ea7a0f5bd/base-util-constructor-config.xml
Diff Regression patch config: https://gist.githubusercontent.com/Lmh-java/ca0caa46b1f782eaf967eddd917cbda7/raw/c3090400a908dce63cb1ac792462fe1d102dac74/patch-util-constructor-config.xml
Diff Regression projects: https://gist.githubusercontent.com/Lmh-java/995679903bfdee2f3b1a8ab2e1578493/raw/068a288ff3424ad4f8c48e8667f1aeef32a6c825/skip-annotation-projects.properties