-
Notifications
You must be signed in to change notification settings - Fork 18
Replace PMD used by the engine
The Code Climate engine is a Docker image which basically wraps a custom PMD version. Contributions made to PMD will not be automatically used by the Code Climate engine. You have to locally build a stripped-down (only Apex-relevant jars) version of PMD and add / replace the jars in the engine.
-
Fork the Apex Metrics engine and connect the repository to your Eclipse and import it as a general project in Eclipse.
-
Download the latest PMD binary distribution from https://github.com/pmd/pmd/releases
-
From the lib folder remove all the .jars not required for PMD-Core, PMD-Apex, PMD-Visualforce.
-
Replace the content of
/codeclimate-apexmetrics/lib/pmd
with the content of your reduced lib folder. -
Make sure that the file
/codeclimate-apexmetrics/lib/pmd/bin/run.sh
is executable. If it is not usechmod +x run.sh
Otherwise the engine will later fail to run as described here: https://github.com/Up2Go/codeclimate-apexmetrics/issues/40.
Build and test your custom engine locally
First you need to install Docker and the Code Climate CLI.
-
Start Docker deamon (On MacOsX by opening Docker Quickstart Terminal) and check if it is running by executing docker images If you get
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
you need to executeeval "$(docker-machine env default)"
. Here is why. -
Navigate into your
codeclimate-apexmetrics
-
[OPTIONAL] Delete previous versions of the apexmetric engine with
docker rmi <Engine Hash>
-
Build the Docker image
docker build -t codeclimate/codeclimate-apexmetrics .
-
Check if there is a
codeclimate/codeclimate-apexmetrics
imagedocker images
-
Update the CodeClimate CLI on your machine by executing those commands
brew update brew upgrade codeclimate
-
Download and unzip big open source repos for testing. E.g.:
-
Run the newly built engine in the root directory of each repository by executing
codeclimate analyze -e apexmetrics
If the analysis is successful it should show issue output like this. If an error occurs try to understand the root cause and fix it BEFORE you can proceed with the last step!
... 83: The method getInit() has an NCSS line count of 61 [apexmetrics] == src/classes/TableGridUtils.cls (1 issue) == 53: Avoid long parameter lists [apexmetrics] Analysis complete! Found 22 issues.
-
Commit your changes to your fork and create a Pull Request to merge your changes. You should provide a detailed description of your changes, why you did them and how you tested them. After we checked and merged your pull request we will publish your changes to Code Climate.