Hi all, i seem to have a problem with one of the code that was mentioned in the pmd guide which basically give a step by step instruction on creating a custom rule set. Below dictates the particular piece of code that i had a problem with which was obtained from https://pmd.github.io/pmd-5.3.6/customizing/howtowritearule.html
As Mentioned in the guide, start() should be called before the visit method is called. Correspondingly, when all the ASTExpression nodes have been visited, the end method would be called. However when i ran this piece of code, this did not seem to be the case as the visit method was called first before the start method. This led to a null pointer exception at "total.incrementAndGet()" as the count variable was not set into the rule context. Does anyone have any solution to this problem?
Last edit: John 2016-05-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
start() should be called before any visit methods - if this is not the case, then you've found a bug in PMD...
Which version of PMD are you using? How to you execute your rule? (via command line, ant, maven, gradle, ...)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all, i seem to have a problem with one of the code that was mentioned in the pmd guide which basically give a step by step instruction on creating a custom rule set. Below dictates the particular piece of code that i had a problem with which was obtained from https://pmd.github.io/pmd-5.3.6/customizing/howtowritearule.html
As Mentioned in the guide, start() should be called before the visit method is called. Correspondingly, when all the ASTExpression nodes have been visited, the end method would be called. However when i ran this piece of code, this did not seem to be the case as the visit method was called first before the start method. This led to a null pointer exception at "total.incrementAndGet()" as the count variable was not set into the rule context. Does anyone have any solution to this problem?
Last edit: John 2016-05-20
start()
should be called before any visit methods - if this is not the case, then you've found a bug in PMD...Which version of PMD are you using? How to you execute your rule? (via command line, ant, maven, gradle, ...)
Hi i'm actually using pmd eclipse plugin 5.4.1.
Maybe it is this bug? https://sourceforge.net/p/pmd/bugs/974/
Yes i would assume so, i am switching over to the stand alone pmd instead. I am also thinking of looking at pmd maven
FYI - the mentioned bug in the eclipse plugin is fixed now.
You can test the new version by installing the latest plugin version from
https://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site-latest/