2021-08-20 16:12:05 +02:00
# PMD - source code analyzer
2012-11-17 17:00:27 +01:00
2024-09-13 09:59:51 +02:00
![PMD Logo ](https://raw.githubusercontent.com/pmd/pmd/pmd/main/docs/images/logo/pmd-logo-300px.png )
2020-09-17 11:02:02 +02:00
2023-02-17 09:12:32 +01:00
[![Join the chat ](https://img.shields.io/gitter/room/pmd/pmd )](https://app.gitter.im/#/room/#pmd_pmd:gitter.im?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge& utm_content=badge)
2024-09-26 15:54:08 +02:00
[![Build Status ](https://github.com/pmd/pmd/actions/workflows/build.yml/badge.svg?branch=main )](https://github.com/pmd/pmd/actions)
2017-02-03 16:27:38 -03:00
[![Maven Central ](https://maven-badges.herokuapp.com/maven-central/net.sourceforge.pmd/pmd/badge.svg )](https://maven-badges.herokuapp.com/maven-central/net.sourceforge.pmd/pmd)
2024-05-03 19:57:57 +02:00
[![Reproducible Builds ](https://img.shields.io/badge/Reproducible_Builds-ok-green?labelColor=blue )](https://github.com/jvm-repo-rebuild/reproducible-central/tree/master/content/net/sourceforge/pmd#readme)
2017-07-08 20:42:58 +02:00
[![Coverage Status ](https://coveralls.io/repos/github/pmd/pmd/badge.svg )](https://coveralls.io/github/pmd/pmd)
2024-05-03 19:57:57 +02:00
[![Codacy Badge ](https://app.codacy.com/project/badge/Grade/ea550046a02344ec850553476c4aa2ca )](https://app.codacy.com/organizations/gh/pmd/dashboard)
2020-04-17 16:13:34 +02:00
[![Contributor Covenant ](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg )](code_of_conduct.md)
2023-03-30 15:28:56 +02:00
[![Documentation (latest) ](https://img.shields.io/badge/docs-latest-green )](https://docs.pmd-code.org/latest/)
2015-11-14 17:53:52 +01:00
2024-05-03 19:47:22 +02:00
**PMD** is an extensible multilanguage static code analyzer. It finds common programming flaws like unused variables,
empty catch blocks, unnecessary object creation, and so forth. It's mainly concerned with **Java and
Apex**, but **supports 16 other languages** . It comes with **400+ built-in rules** . It can be
extended with custom rules. It uses JavaCC and Antlr to parse source files into abstract syntax trees
(AST) and runs rules against them to find violations. Rules can be written in Java or using a XPath query.
Currently, PMD supports Java, JavaScript, Salesforce.com Apex and Visualforce,
Kotlin, Swift, Modelica, PLSQL, Apache Velocity, JSP, WSDL, Maven POM, HTML, XML and XSL.
2022-11-10 23:33:08 +00:00
Scala is supported, but there are currently no Scala rules available.
2012-11-17 17:00:27 +01:00
2023-02-16 19:24:32 +01:00
Additionally, it includes **CPD** , the copy-paste-detector. CPD finds duplicated code in
2024-05-03 19:47:22 +02:00
Coco, C/C++, C#, Dart, Fortran, Gherkin, Go, Groovy, HTML, Java, JavaScript, JSP, Julia, Kotlin,
Lua, Matlab, Modelica, Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex and
Visualforce, Scala, Swift, T-SQL, Typescript, Apache Velocity, WSDL, XML and XSL.
2021-08-20 16:12:05 +02:00
## 🚀 Installation and Usage
Download the latest binary zip from the [releases ](https://github.com/pmd/pmd/releases/latest )
and extract it somewhere.
2023-03-30 15:28:56 +02:00
Execute `bin/pmd check` or `bin\pmd.bat check` .
2021-08-20 16:12:05 +02:00
2023-03-30 15:28:56 +02:00
See also [Getting Started ](https://docs.pmd-code.org/latest/pmd_userdocs_installation.html )
2021-08-20 16:12:05 +02:00
**Demo:**
2024-03-01 08:29:30 +01:00
This shows how PMD analyses [openjdk ](https://github.com/openjdk/jdk ):
2021-08-20 16:12:05 +02:00
2021-09-02 12:20:34 +02:00
![Demo ](docs/images/userdocs/pmd-demo.gif )
2021-08-20 16:12:05 +02:00
There are plugins for Maven and Gradle as well as for various IDEs.
2023-03-30 15:28:56 +02:00
See [Tools / Integrations ](https://docs.pmd-code.org/latest/pmd_userdocs_tools.html )
2021-08-20 16:12:05 +02:00
## ℹ ️ How to get support?
2020-02-15 19:07:20 +01:00
2021-01-07 12:09:10 +01:00
* How do I? -- Ask a question on [StackOverflow ](https://stackoverflow.com/questions/tagged/pmd )
or on [discussions ](https://github.com/pmd/pmd/discussions ).
* I got this error, why? -- Ask a question on [StackOverflow ](https://stackoverflow.com/questions/tagged/pmd )
or on [discussions ](https://github.com/pmd/pmd/discussions ).
2020-02-15 19:07:20 +01:00
* I got this error and I'm sure it's a bug -- file an [issue ](https://github.com/pmd/pmd/issues ).
2021-01-07 12:09:10 +01:00
* I have an idea/request/question -- create a new [discussion ](https://github.com/pmd/pmd/discussions ).
2023-02-17 09:12:32 +01:00
* I have a quick question -- ask in our [Gitter room ](https://app.gitter.im/#/room/#pmd_pmd:gitter.im ).
2023-03-30 15:28:56 +02:00
* Where's your documentation? -- < https: // docs . pmd-code . org / latest />
2020-02-15 19:07:20 +01:00
2021-08-20 16:12:05 +02:00
## 🤝 Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
2013-05-01 14:56:22 +02:00
2017-01-05 11:27:08 +01:00
Our latest source of PMD can be found on [GitHub ](https://github.com/pmd/pmd ). Fork us!
2015-11-14 17:53:52 +01:00
2017-01-05 11:27:08 +01:00
* [How to build PMD ](BUILDING.md )
* [How to contribute to PMD ](CONTRIBUTING.md )
2015-11-14 17:53:52 +01:00
2019-03-03 11:54:41 +01:00
The rule designer is developed over at [pmd/pmd-designer ](https://github.com/pmd/pmd-designer ).
Please see [its README ](https://github.com/pmd/pmd-designer#contributing ) for
developer documentation.
2021-09-09 15:03:32 +02:00
## 💵 Financial Contributors
2021-08-20 16:12:05 +02:00
Become a financial contributor and help us sustain our community. [Contribute ](https://opencollective.com/pmd/contribute )
2021-08-20 16:16:31 +02:00
## ✨ Contributors
2021-09-09 14:50:32 +02:00
This project follows the [all-contributors ](https://github.com/all-contributors/all-contributors ) specification.
Contributions of any kind welcome!
2021-08-20 16:16:31 +02:00
2021-09-09 14:50:32 +02:00
See [credits ](docs/pages/pmd/projectdocs/credits.md ) for the complete list.
2021-08-20 16:16:31 +02:00
2021-08-20 16:12:05 +02:00
## 📝 License
2015-11-14 17:53:52 +01:00
2021-08-20 16:12:05 +02:00
[BSD Style ](LICENSE )