-
Notifications
You must be signed in to change notification settings - Fork 18
Add or improve existing PMD rules
David Renz edited this page May 30, 2016
·
34 revisions
If you want to add rules that work similarly to the ones we already have you will have to extend PMD itself. Those are the steps you need to do:
- Install latest Eclipse IDE for Java Developers
- Fork PMD (https://github.com/pmd/pmd)
- Connect your eclipse with master branch of your PMD repo
- Import the project as general project
- Delete the project, uncheck the Delete project contents on disk and copy the project location
- Import them as existing Maven Projects and auto-resolve problems
- Create a new rule (example AvoidDmlInLoops)
- Use a similar rule as starting point and adapt it
- Add rule definition to the ruleset of its category and the complete ruleset
- Add the rule to the according Test class
- Create a new xml file with test cases
- Run your unit tests
- Install Maven (
brew install maven
if you are using Homebrew) - To build PMD navigate to the root directory of PMD and execute
mvn clean package
- After building PMD navigate to
/pmd/pmd-dist/target
and unzippmd-bin-5.5.0-SNAPSHOT.zip
- Run PMD
pmd-bin-5.5.0-SNAPSHOT/bin/run.sh pmd -d /files/to/analyse -f text -R apex-ruleset
- Synchronize your workspace with your repository
- Compare and check your changes and commit them
- Create a pull request