PMD
PMD is an easy to use, extensible, multi-language static code analysis tool. It is intended to find and report common programming flaws, such as:
- Unused variables
- Empty catch blocks
- Unnecessary object creation
- Copy-pasted code
PMD is designed to be integrated directly into a build process or continuous integration tools, acting as a automatic quality gate and enforcing code standards within a codebase. PMD provides plugins for several such tools, including Maven, Gradle, Ant, GitHub Actions, and Jenkins, as well as a standalone version for command-line usage.
PMD operates by parsing source files into abstract syntax trees (AST) and applies rules over this tree to detect violations. Alongside pre-configured rules for languages, PMD supports the addition of custom rules to aid users in defining coding standards for their applications. This includes a graphical Rule Designer tool to help in custom rule development.
PMD’s AST analysis supports a variety of languages, including Java, JavaScript, Scala, Apex, Visualforce, and XML. The copy paste detector module (which does not use the AST) functions on most modern programming languages.