codeclimate is a command line interface for the Code Climate analysis
platform. It allows you to run Code Climate engines on your local machine inside
of Docker containers.
The Code Climate CLI is distributed and run as a
Docker image. The engines that perform the actual
analyses are also Docker images. To support this, you must have Docker installed
and running locally. We also require that the Docker daemon supports connections
on the default Unix socket /var/run/docker.sock.
On macOS, we recommend using Docker for Mac.
docker pull codeclimate/codeclimatedocker 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 helpThe above is very transparent. It's clear what's happening, and any changes required to work with your specific Docker setup can be discovered easily. That said, it can be unwieldy to invoke such a command on a regular basis.
For this reason, we also provide packages that include a small wrapper script for the above invocation:
brew tap codeclimate/formulae
brew install codeclimateTo update the brew package, use brew update first:
brew update
brew upgrade codeclimatecurl -L https://github.com/codeclimate/codeclimate/archive/master.tar.gz | tar xvz
cd codeclimate-* && sudo make installTo upgrade to a newer version, just run those steps again.
A list of available commands is accessible by running codeclimate or
codeclimate help.
$ codeclimate help
Available commands:
analyze [-f format] [-e engine(:channel)] [--dev] [path]
console
engines:install
engines:list
help
validate-config
versionThe following is a brief explanation of each available command.
-
analyzeAnalyze all relevant files in the current working directory. All engines that are enabled in your.codeclimate.ymlfile will run, one after another. The-f(orformat) argument allows you to set the output format of the analysis (usingjson,text, orhtml). The--devflag lets you run engines not known to the CLI, for example if you're an engine author developing your own, unreleased image.You can optionally provide a specific path to analyze. If not provided, the CLI will analyze your entire repository, except for your configured
exclude_paths. When you do provide an explicit path to analyze, your configuredexclude_pathsare ignored, and normally excluded files will be analyzed.You can also pipe in source in combination with a path to analyze code that is not yet written to disk. This is useful when you want to check if your source code style matches the project's. This is also a good way to implement integration with an editor to check style on the fly.
-
consolestart an interactive session providing access to the classes within the CLI. Useful for engine developers and maintainers. -
engines:installCompares the list of engines in your.codeclimate.ymlfile to those that are currently installed, then installs any missing engines. -
engines:listLists all available engines in the Code Climate Docker Hub . -
helpDisplays a list of commands that can be passed to the Code Climate CLI. -
validate-configValidates the.codeclimate.ymlfile in the current working directory. -
versionDisplays the current version of the Code Climate CLI.
-
To run
codeclimatein debug mode:CODECLIMATE_DEBUG=1 codeclimate analyzePrints additional information about the analysis steps, including any stderr produced by engines.
-
To increase the amount of time each engine container may run (default 15 min):
# 30 minutes CONTAINER_TIMEOUT_SECONDS=1800 codeclimate analyze -
You can also configure the default alotted memory with which each engine runs (default is 1,024,000,000 bytes):
# 2,000,000,000 bytes ENGINE_MEMORY_LIMIT_BYTES=2000000000 codeclimate analyze
See LICENSE