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 — [apex] Fix #5906: MethodWithSameNameAsEnclosingClass range is too broad by HawkForge · Pull Request #7264 · pmd/pmd Conversation
Contributor
Describe the PRFixes the too-broad violation range of the Apex rule MethodWithSameNameAsEnclosingClass. Thanks to @stephen-carter-at-sf for the report. The rule called addViolation(node) on the ASTMethod, so the reported range covered the whole method including its body. It now reports the range from the start of the method to the end of its signature (the text before the body block), as was done for ExcessiveParameterList in #5617. Two test cases were added (multi-line signature with parameters, and a no-parameter method) using expected-linenumbers ranges. They fail without the change. Related issues
Ready?
Replaces #7227, which got closed when my fork was accidentally detached.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…the method signature
|
There was an error while loading. Please reload this page.
|
Would it make sense to override pmd-java does the same thing in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
good call, thanks. moved it into |
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: UncleOwen <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
apex has no identifier token on the method node like java does, so i couldn't just return that.
It's true, that in PMD's AST of Apex, there is no identifier node and no token. But we could use the underlying node from SummitAst, which has the identifier (unfortunately, it is not a field, because there are synthetic methods for triggers, that don't have a node).
I'll give that a try... it would make it easier, if we could just use the sourceLocation of the identifier then (and ExcessiveParameterList rule could then be simplified as well).
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This change now also fixes #5669. I didn't change ExcessiveParameterList, as there it makes sense to also return the range over the parameters. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Compared to main: (comment created at 2026-11-20 19:45:00+00:00 for d2dc1be) |
Sorry, something went wrong.
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.
[apex] MethodWithSameNameAsEnclosingClass: Violation range should only cover the method name
There was an error while loading. Please reload this page.