Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[apex] ClassCastException caused by Javadoc #1396
Affects PMD Version: 6.8.0
Description: ClassCastException occurs when running
Code Sample demonstrating the issue:
Running PMD through: CLI
referenced this issue
Oct 17, 2018
@rsoesemann It looks like it, though I'm not sure how I didn't run into it during testing.
I think we could just make
Though I'm wondering if we should also change the
added a commit
Oct 19, 2018
Hi @jeffhube ,
For the problem at hand, it doesn't make any difference. We could delegate always to visit(AbstractApexNodeBase, Object), which looks nicer and more consistent.
Let me know, if you want to create a PR with your patch or whether I can just take your fix and integrate it - either way is fine.
So the reason I brought up changing the visitor here is because it seems that the rules fail because while visit(ApexNode<?>, Object) used to be called for every node, that is not the case now, since ASTFormalComment is not an ApexNode<?>. One way to work around that is to implement visit(ASTFormalComment, Object) as I had for AbstractNcssCountRule, but I am thinking that we may be better off getting back to having a visit method that is called for every node, which would be visit(AbstractApexNodeBase, Object), and then AbstractNcssCountRule and ExcessiveNodeCountRule would override that instead of visit(ApexNode<?>, Object), and the override of visit(ASTFormalComment, Object) that I added would be removed.
The options I see for doing so would be:
Regardless, feel free to just take my changes and integrate them as you see fit.
Thanks for your suggestions.
Option 1 is almost possible as you described it: it would change the implementation of the visitor in AbstractApexRule. If we directly delegate to visit(AbstractApexNodeBase), we can reduce the stack size (in comparison to delegate to visit(ApexNode) which delegates then to visit(AbstractApexNodeBase)). Removing visit(ApexNode) should not be done, but we can deprecate it and mark it for removal for PMD 7.0.0. Unless there is a usecase to visit only all nodes except for ASTFormalComments....
For you 2 option: I think, changing AbstractNcssCountRule and ExcessiveNodeCountRule should be changed to override visit(AbstractApexNodeBase) in any case...
Will do, thanks again!