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  ./ 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


Creating/Changing Ruleset

After running sometimes you can see that some rules are not necessary, so then you edit the ruleset:


<rule ref=”rulesets/java/basic.xml/EmptyCatchBlock”

  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:


./run designer


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:





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s