Run Code Climate Locally

Empress
2 min readJan 20, 2019

--

Code climate logo (BrandEPS)

Getting the code quality only when pushing to a git repository requiring code quality check can be quite exhausting. While I struggled with this for a while, I then found a way using docker following this documentation but it didn’t seem to work. Finally got it to working and decided to document the steps I used for anyone who needs it.

Prerequisite:

  • Install and setup using Docker for mac
  • Pull code climate image to your machine using docker pull codeclimate/codeclimate
  • To support this installation, code climate package is installed using the commands
OS X:
brew tap codeclimate/formulae
brew install codeclimate
Other operating systems:
curl -L https://github.com/codeclimate/codeclimate/archive/master.tar.gz | tar xvz
cd codeclimate-* && sudo make install

Shell script:
Copy the command script below and save to a file named codeclimate.sh

sudo docker run \--interactive --tty --rm \--env CODECLIMATE_CODE="$PWD" \--volume "$PWD":/code \--volume /var/run/docker.sock:/var/run/docker.sock \--volume /tmp/cc:/tmp/cc \codeclimate/codeclimate analyze

Move to bin folder making it global:sudo mv codeclimate.sh /usr/local/bin/codeclimate

Change the access right to make the script runnable using:

cd /usr/local/bin/ && sudo chmod 755 codeclimate

Run codeclimate on the terminal location containing .codeclimate.yml

Results fromcodeclimate can be written to a file using codeclimate > ../filename.html

More commands for customization of the shell script can be found here.

Thanks for stopping by and I do hope you found this article somewhat helpful 😉.

--

--