GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — [java] AvoidCallingFinalize detects some false positives (2578) by Drofff · Pull Request #2643 · pmd/pmd Conversation
Contributor
Describe the PRI have modified the AvoidCallingFinalizeRule class to fix false positives when variables with name 'finalize' and finalize methods with args are detected as a problem. Also I've added 2 tests validating that the false positive bugs were fixed. Related issuesReady?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
Generated by 🚫 Danger |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@Drofff thanks for the contribution! Glad to get new devs onboard!
One thing I do notice is that you are now reporting the violation on the block node. This has 2 consequences:
if (foo) { // <-- violation reported here bar(); // do stuff finalize(); // <-- actual illegal invocation is way down here //maybe more code… }
if (foo) { // <-- 2 violations reported here bar.finalize(); // <-- actual illegal invocation 1 is here // do stuff finalize(); // <-- actual illegal invocation 2 is here //maybe more code… }
I'd try and call addViolation on the node that corresponds to the actual invocation.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@jsotuyod thank you for your time and clear explanation! I've changed the code to use addViolation on the proper node and have fixed getArgsCount method mistake (I hope so |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@Drofff awesome! thanks for the quick response! The only thing I'm seeing is that the regression tester says we seem to have introduced a false negative now… The report says we removed a FP (yay! 🎉 ) but are also no longer reporting this |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
I'll change the rule to use the rulechain when merging.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (isIncorrectFinalizeMethodCall(primaryExpression)) { | ||
| addViolation(data, primaryExpression); | ||
| } | ||
| return data; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
To be fully correct, we need to call here either super or need to use the rule chain. A primary expression could define a anonymous class, which in turn could have primary expressions which call the finalize method....
Sorry, something went wrong.
There was an error while loading. Please reload this page.
[java] AvoidCallingFinalize detects some false positives (2578) #2643
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[java] AvoidCallingFinalize detects some false positives
There was an error while loading. Please reload this page.