PMD Fundaments: Up the Tree or Down the Tree? #4932
Replies: 3 comments 3 replies
-
There is the option to shut down the traversal during the statement vist (just not hit the super.) Right? |
Beta Was this translation helpful? Give feedback.
-
PMD is REALLY efficient and will visit all nodes by default, as long as you are not doing anything silly it should not be an issue at all. This seems like early optimization. I'd advise you get something to working, and then ask for insight if performance is an issue. |
Beta Was this translation helpful? Give feedback.
-
Juan's advice about early optimization is valid. FWIW to get the best results you need to consider two things in order:
In your case, there might be a way to traverse fewer nodes than just all method declarations. You could traverse only those method declarations that contain at least an increment operation. This would save work because the increment statements should be rarer than method declarations in general (there are many method declarations that don't contain any increment). So you could make your rule extend |
Beta Was this translation helpful? Give feedback.
-
I almost want to use a "cat in a tree" analogy here after reading my title.
I'm trying to find instances of counterfeit test coverage. The most common anti-pattern for this is a bunch of increment statements (i++ etc.) For "reasons" I'm doing this in a Java rule.
Is it more efficient to start at the atomic level (the statement visitor) or the method level (the method visitor)?
Better to let visit get hit a bunch of times and walk up the tree, or less hits to visit and walk down the tree? Which is most efficient within the domain of PMD?
Beta Was this translation helpful? Give feedback.
All reactions