Issue #14950: Add new property to UnusedLocalVariable to suppress violtions on unnamed variables#15187
Conversation
|
If you move first commit to separate PR, I will merge it by single review. |
d1fc9ce to
da3effb
Compare
|
github, generate site |
da3effb to
48f0cc6
Compare
|
github, generate report |
|
github, generate report |
|
github, generate report |
|
github, generate report |
|
@nrmancuso @rnveach ping |
|
@mahfouz72 In the future, can you label the regressions for us on what they are if there are multiple and hide the ones we shouldn't be looking at if they are old. I believe GH regression action accepts labels as a parameter but I don't use it so I don't know what it is. I expect to see regression on
|
|
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/48f0cc6_2024161154/reports/diff/checkstyle/index.html#A28 https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/48f0cc6_2024161154/reports/diff/openjdk21/index.html#A1 |
There was no violation before check got confused on line 8. and registered
Yes, the check currently ignores try we should add support for try in this check in another issue and the exception parameter is not even considered a local variable so it is ik to get ignored by this check, catch parameters needs a new check
Yes |
48f0cc6 to
749efc5
Compare
|
github, generate site |
b012841 to
97f1f24
Compare
|
github, generate site |
Please make an issue for this. We won't attach it to GSoC.
Think this answers me. It won't compile pre-9 because of multiple variables with the same name, but after 21 it is because of the unnamed. I was wrongly thinking this was a pre-9 file. |
rnveach
left a comment
There was a problem hiding this comment.
I am good, but the following need to be done:
…ppress violtions on unnamed variables
97f1f24 to
2d34f38
Compare
@rnveach sorry I missed something. this won't compile before Java 9. You can't have two variables with the same name. accordingly, This is not a bug that affects either Java 9 or Java21+. Do you agree? |
Based on this comment, I will let @rnveach merge this PR once he is good. |
|
@mahfouz72 Isn't this a bug before Java 9 that there aren't 2 violations, both on the |
The thing is that this method is not compilable before java 9. You can't have 2 variables with the same name in a single scope
validating a resource is another issue #15024 |
|
ok, maybe I will look into a bit but it seems a concern that this check thinks a try-with-resource is a usage. My concerns are resolved for now. |
It is a concern of course but doesn't result in a bug. if it works don't touch it : )
Then please merge when you can this is left for you to merge |
You can't prove it "works" if we can't say it will never be a problem. The only way we have seen it is with duplicate variable name which isn't valid. We haven't ruled out all circumstances, which is what I want to try and look into. BTW, isn't this still a bug on Java 21+ if you don't suppress unnamed variables? Nothing says this has to be enabled if you are on a high enough java version. |
yes , but it is very nonsense if I am on java 21+ and want to violate all unnamed variables as unused |
|
If you want I can opem issue to remember this once I am on laptop |
|
Continuing on for bug at #15187 (comment), It appears our It picked up I am going to run regression with a change and see if anything pops up. Edit: |
|
https://rveach.no-ip.org/checkstyle/regression/1/openjdk17/index.html#A3 Making a change and trying another run. |
yeah, then it should be ignored onlt if it is a new variable declaration not a usage of previous variable |
|
https://rveach.no-ip.org/checkstyle/regression/2/ Second regression showed less cases. This still seems like a concern that I am going to merge this PR for now. |
closes #14950:
Diff Regression config: https://gist.githubusercontent.com/mahfouz72/afd57aa6e51ca161b7927acd959e5211/raw/73fb0891a2bf6813dbebdd94abfb20429efd227b/check.xml
Diff Regression patch config: https://gist.githubusercontent.com/mahfouz72/33967bf86e4a29cafa429771b0e95808/raw/6de640382dd85765496efb44cae1b60a43706115/check_patch.xml
Diff Regression projects: https://gist.githubusercontent.com/mahfouz72/a3d0af030c8f5efd0d8a39f2c14750bc/raw/a3424ad9b6f722e5de1a927e3d85e383101b2b93/projects-to-test-on.properties