Code Climate CLI
Latest commit e2f7d7f Nov 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Convert to circle 2.0 Aug 27, 2018
benchmarks PathTree extract node types into separate classes Feb 18, 2016
bin Use `/bin/bash` shebang for non-POSIX shell scripts. (#849) Jul 4, 2018
config Add v0.60.0 channel to Rubocop engine (#884) Nov 8, 2018
lib/cc Only pass `--memory` option to Docker if a memory limit is set. (#843) Jun 21, 2018
spec Switch upstream Docker image to ruby:alpine (#840) Jun 20, 2018
.codeclimate.yml Switch to Rubocop 0.57.x, fix fixme's exclusion config. (#852) Jul 5, 2018
.dockerignore Convert to circle 2.0 Aug 27, 2018
.gitignore Git ignore `base_rubocop.yml` (#779) Nov 16, 2017
.rubocop.yml Fix CC issues Apr 15, 2016
.ruby-style.yml Open source commit Jun 19, 2015
.ruby-version Open source commit Jun 19, 2015
DEVELOPERS.md Document a couple prerequisites to releasing Nov 17, 2017
Dockerfile Use `alpine` instead of `ruby` base image; 100MB vs. 180MB. (#842) Jun 21, 2018
Gemfile Alphabetize gem dependency list. (#850) Jul 5, 2018
Gemfile.lock Release v0.82.0 (#885) Nov 9, 2018
ISSUE_TEMPLATE.md Add information about using as a gem Aug 17, 2016
LICENSE Update license Apr 27, 2017
Makefile Always pull base image before building Sep 17, 2018
README.md codeclimate prepare Aug 21, 2018
Rakefile Output test results in JUnit XML for CircleCI May 7, 2016
VERSION Release v0.82.0 (#885) Nov 9, 2018
WERE_HIRING.md Enable markdownlint and fix issues Aug 24, 2016
codeclimate-wrapper Correct `shellcheck` issues in the bin wrapper script. (#851) Jul 6, 2018
codeclimate.gemspec Prefer YAML.safe_load to SafeYaml Nov 16, 2017

README.md

Code Climate CLI

Code Climate

Overview

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.

Prerequisites

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.

Installation

docker pull codeclimate/codeclimate

Usage

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 help

Packages

The 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:

OS X

brew tap codeclimate/formulae
brew install codeclimate

To update the brew package, use brew update first:

brew update
brew upgrade codeclimate

Anywhere

curl -L https://github.com/codeclimate/codeclimate/archive/master.tar.gz | tar xvz
cd codeclimate-* && sudo make install

To upgrade to a newer version, just run those steps again.

Commands

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 [command]
    prepare [--allow-internal-ips]
    validate-config
    version

The following is a brief explanation of each available command.

  • analyze Analyze all relevant files in the current working directory. All engines that are enabled in your .codeclimate.yml file will run, one after another. The -f (or format) argument allows you to set the output format of the analysis (using json, text, or html). The --dev flag 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 configured exclude_paths are 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.

  • console start an interactive session providing access to the classes within the CLI. Useful for engine developers and maintainers.

  • engines:install Compares the list of engines in your .codeclimate.yml file to those that are currently installed, then installs any missing engines.

  • engines:list Lists all available engines in the Code Climate Docker Hub .

  • help Displays a list of commands that can be passed to the Code Climate CLI.

  • validate-config Validates the .codeclimate.yml file in the current working directory.

  • version Displays the current version of the Code Climate CLI.

Environment Variables

  • To run codeclimate in debug mode:

    CODECLIMATE_DEBUG=1 codeclimate analyze
    

    Prints 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
    

Copyright

See LICENSE