Learning a bit more about statical validation of JAVA code ~ as a counterpart for Lint my python scripts, then it would be unavoidable to look for issues on my code.
So as a first statical validation tool, the basic features below:
You can run PMD in Windows and Linux, after installing, ofc. Below the running with basic quickstart rules that comes within the tool:
522 ./run.sh pmd -d /c/Users/TechPro/Desktop/lugano -rulesets rulesets/java/quickstart.xml,category/java/codestyle.xml > output1.txt
523 pmd -d /c/Users/TechPro/Desktop/lugano -f text -R rulesets/java/quickstart.xml> output2.txt
After running sometimes you can see that some rules are not necessary, so then you edit the ruleset:
message=”Must handle exceptions”>
Creating new rules
But then, you need to create some new rules, like this one here, which validates a string that I’m creating.
To create a new rule, basically just run the designer, which comes with bin directory of PMD. As below:
To create the rule, you will need to create a rule on the XPath Expression, which is done by the AST tree validation, as below: