phppmd

How to use "pmd check" to scan for language php?


im sorry its very very newbie question. But I dont know where to find pmd rules for php.

I am properly able to run

pmd check -R rulesets/java/quickstart.xml -f text --dir MyProject

But not for php

pmd check -R rulesets/php/quickstart.xml -f text --dir MyProjectPhp

I understand by reading the jar file that ruleset/java is an Internal ruleset, but where is the php ruleset, it does exist open source? Is it the correct usage syntax, or will I need to use -l php somehow?

Thank you for your patience with a newbie.

I tried pmd check -R rulesets/php/quickstart.xml -f text --dir MyProjectPhp and expected it existed as internal ruleset or a directory somewhere.


Solution

  • The list of languages supported by the latest version of PMD (7.2) is given in the project home page:

    Currently, PMD supports Java, JavaScript, Salesforce.com Apex and Visualforce, Kotlin, Swift, Modelica, PLSQL, Apache Velocity, JSP, WSDL, Maven POM, HTML, XML and XSL. Scala is supported, but there are currently no Scala rules available.

    As you can see, PHP is not one of them.

    You may take a look at PHPMD instead, which is a tool inspired by PMD and dedicated to PHP.