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 — [kotlin] Fix #6732: Add LocalVariableShadowsParameter rule by stokpop · Pull Request #6733 · pmd/pmd Conversation
Contributor
Adds the Closes #6732.
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.
|
Compared to main: (comment created at 2026-06-04 15:45:58+00:00 for 605a7a2) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What do you think about adding other examples of shadowing to this rule? e.g. a block-scoped variable shadowing one defined at method scope? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
ok, an example would be: Yes, we can add this to this rule.
Shall I add it to this rule? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'll leave that up to you. I just wanted to mention the possibility. Both versions (one rule for all shadowing cases or separate rules) are fine. |
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.
Thanks, looks good!
What do you think about adding other examples of shadowing to this rule? e.g. a block-scoped variable shadowing one defined at method scope?
Shall I add it to this rule?
If so, maybe name should then also change to "LocalVariableShadowing".
I'd say, we keep it simple for now. This can be added later if needed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| if (!KotlinAstUtil.isWithin(propDecl, KtFunctionDeclaration.class, func)) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Just a note: In Java we have the concept of find boundaries, e.g. you can call node.descendants(KtPropertyDeclaration.class).crossFindBoundaries() to explicitly say: If there are nested classes, continue the search inside these and cross the find boundary.
By default I think, we do not cross the boundaries, so in theory, this if statement would not be necessary.
But it needs support in the AST and we probably don't have this feature in ANTLR. The AST nodes would need to implement net.sourceforge.pmd.lang.ast.Node#isFindBoundary, e.g. KtClassDeclaration would need to return true. But as we don't have AST nodes that we can change, I think adding the if statement is currently the only way to achieve 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.
Co-authored-by: Andreas Dangel <[email protected]>
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[kotlin] New Rule: LocalVariableShadowsParameter
There was an error while loading. Please reload this page.