2021-08-20 16:12:05 +02:00
# PMD - source code analyzer
2012-11-17 17:00:27 +01:00
2020-09-17 11:02:02 +02:00
![PMD Logo ](https://raw.githubusercontent.com/pmd/pmd/pmd/7.0.x/docs/images/logo/pmd-logo-300px.png )
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)
2021-04-15 16:20:22 +02:00
[![Build Status ](https://github.com/pmd/pmd/workflows/build/badge.svg?branch=master )](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)
2020-09-17 12:04:14 -04:00
[![Reproducible Builds ](https://img.shields.io/badge/Reproducible_Builds-ok-green?labelColor=blue )](https://github.com/jvm-repo-rebuild/reproducible-central#net.sourceforge.pmd:pmd)
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)
2023-02-17 09:12:32 +01:00
[![Codacy Badge ](https://app.codacy.com/project/badge/Grade/ea550046a02344ec850553476c4aa2ca )](https://www.codacy.com/gh/pmd/pmd/dashboard?utm_source=github.com& utm_medium=referral& utm_content=pmd/pmd& utm_campaign=Badge_Grade)
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)
2021-08-20 16:12:05 +02:00
[![Documentation (latest) ](https://img.shields.io/badge/docs-latest-green )](https://pmd.github.io/latest/)
2015-11-14 17:53:52 +01:00
2017-01-05 11:27:08 +01:00
**PMD** is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks,
2021-08-20 16:12:05 +02:00
unnecessary object creation, and so forth. It supports many languages. It can be extended with custom rules.
2021-09-02 11:14:57 +02:00
It uses JavaCC and Antlr to parse source files into abstract syntax trees (AST) and runs rules against them to find violations.
2021-08-20 16:12:05 +02:00
Rules can be written in Java or using a XPath query.
It supports Java, JavaScript, Salesforce.com Apex and Visualforce,
2023-02-16 19:24:32 +01:00
Modelica, PLSQL, Apache Velocity, 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
C/C++, C#, Dart, Fortran, Gherkin, Go, Groovy, HTML, Java, JavaScript, JSP, Kotlin, Lua, Matlab, Modelica,
Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex and Visualforce, Scala, Swift, T-SQL and XML.
2015-11-14 17:53:52 +01:00
2021-08-20 16:12:05 +02:00
In the future we hope to add support for data/control flow analysis and automatic (quick) fixes where
it makes sense.
## 🚀 Installation and Usage
Download the latest binary zip from the [releases ](https://github.com/pmd/pmd/releases/latest )
and extract it somewhere.
Execute `bin/run.sh pmd` or `bin\pmd.bat` .
See also [Getting Started ](https://pmd.github.io/latest/pmd_userdocs_installation.html )
**Demo:**
2021-09-02 12:20:34 +02:00
This shows how PMD can detect for loops, that can be replaced by for-each loops.
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.
See [Tools / Integrations ](https://pmd.github.io/latest/pmd_userdocs_tools.html )
## ℹ ️ 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 ).
2020-02-15 19:07:20 +01:00
* Where's your documentation? -- < https: // pmd . github . io / latest />
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 )