Skip to content
David Renz edited this page May 27, 2016 · 31 revisions

How To Contribute

There is a lot of room for improvement or extension. Depending on what you want to do you eighter need to fork, extend and pull request this repository or the PMD repository.

Add or improve existing PMD rules

If you want to add rules that work similarly to the ones we already have you will have to extend PMD itsself. Those are the steps you need to do:

Setup development environment

  • Install latest Eclipse IDE for Java Developers
  • Fork PMD (https://github.com/pmd/pmd) [1]
  • Connect your eclipse with master branch of your pmd repo [2,3]
  • Import the project as general project [4]
  • Delete the project, uncheck the Delete project contents on disk and copy the project location [5]
  • Import them as existing Maven Projects and auto-resolve problems [6,7,8]

Add a new rule for Apex PMD

  • Create a new rule (example AvoidDmlInLoops) [9]
  • Use similar rule as starting point and adapt it [10,11]
  • Add rule definition to the ruleset of its category and the complete ruleset [12,13]
  • Add the rule to the according Test class [14]
  • Create a new xml file for the rule with test cases [15]
  • Run your tests to [16,17]

Upgrade PMD version used by the engine

Contributions made to PMD will not be automatically used by the Code Climate engine. You have to replace the current build of PMD in the engine with new one. Those are the steps you need to do:

  1. Adjust the pom.xml of PMD to get a lean build of PMD only with the required Jars, we recommend you to use our pom.xml.

  2. Build PMD. Execute mvn clean packagein the root directory of PMD.

  3. Unzip the generated pmd-bin-5.5.0-SNAPSHOT.zip in the /pmd/pmd-dist/target directory.

  4. Fork the Apex Metrics engine.

  5. Replace the content of /codeclimate-apexmetrics/lib/pmd with the content of your unzipped pmd-bin-5.5.0-SNAPSHOT directory.

  6. Test and execute your custome engine locally or pull request you changes.

Add new engine component

Beside extending the underlying PMD framework people could also add totally new mechanisms to evaluate code. Code would then not only run through PMD but also through other internal components. Just imagine using the Tooling Api and then reporting back on usused code across class boundaries as implemented by Salesforce.com MVP Andrew Fawcett.

Clone this wiki locally