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 #7643: Update doc for IllegalInstantiation #9181
Issue #7643: Update doc for IllegalInstantiation #9181
Conversation
I closed the previous PR #9154 trying to fix the same issue due to problems with branch naming, which is fixed now in this PR. Additional examples were also added at the request of reviewer @romani. I did not add an example for property
Upon testing property
Interestingly, the following configuration yields the result:
I don't know if the check is also supposed to show errors for when the user uses an interface instead of a class. I was expecting using |
@himanshurijal I missed a lot of things in my original review; I apologize. I did not look deeply into the logic for the check and trusted existing documentation too much. You have done well to question the check implementation/ documentation above. After evaluating the code in the check, and reviewing your notes above, there are a few things that I notice: Inclusion of the The table might be confusing, since it does not list the actual tokens that we are checking This check should only show violations on the |
no need, such tokens are required, user can not modify them. It is internal details that we process such tokens. We never do this.
yes! |
Thank you for the detailed explanation @nmancus1 . I now understand what the property However, before I add more examples I wanted to clarify a few things first.
Checkstyle ends without any errors. I am guessing using an empty string leads
Sorry for the lengthy examples. But, I feel like they add more clarity to what I am trying to ask. |
This is correct. After some more digging, I have found this to be true for all checks that are children of checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java Lines 201 to 204 in e5d4378
Using your above examples with contrasting configs: https://gist.github.com/nmancus1/7aa17723f1af911f8a7dec3ff39fde81
Here is a good example of package checking: https://gist.github.com/nmancus1/6c52ad7dbd504f99991a59af72566939
No need for apologies, your examples helped me to help you. Checkstyle has a lot of code, there is no way for anyone to know all of it. Open source is about working together :) I would include some form of all above examples to help users to understand how exactly this check works. Show how package name is used, show how token config affects violations, etc. Any question that you have had while working on this is probably a question that users will have. |
@nmancus1 I updated doc with new examples from our discussion. If you could review when you have time, that'd be great. |
src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheck.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.
Please demonstrate package name checking (where check is aware of the package name and illegal class, so it causes violation since we are in that package) as in my second example (please just use another class though, not boolean). You can add it to one of the existing examples. One other item:
src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheck.java
Outdated
Show resolved
Hide resolved
src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheck.java
Outdated
Show resolved
Hide resolved
src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheck.java
Outdated
Show resolved
Hide resolved
Github, generate site |
nice progress .... unfortunately I found example hard to understand ... main reason is that example java code block is different all the time. Please use:
it might be good to be for all configs.
Please add case in example to make it visual or user.
and
are almost identical by configuration, please merge it to
It is magic for user why |
Thank you for reviewing @romani
Just to be clear. Since you recommended me to use that example for all configs, should I remove examples of |
yes , you can, it is not critical, all we need is to show how to define few items in property, so 2 is enough. |
Understood. I'll make the changes and get back to you. |
@himanshurijal , ping. |
I apologize for the delay. I was really busy with my coursework. I'll be pushing my changes today. |
Some points to note:
|
Github, generate site |
@himanshurijal , thanks a lot for fix. |
Absolutely! Thank you both for guiding me through the process. |
Issue #7643:
I closed the previous PR #9154
Add code example
Output of default example:
Output of non-default example:
Output of non-default example:
Output of non-default example: