Language / Framework: Ruby
Checks: 300
Categories: Complexity, Security, Clarity, Performance, Bug Risk, Style
RuboCop Version: 0.52.1 (other versions including RuboCop 0.54.0 available by channels)

Our RuboCop engine provides style and quality checks for Ruby code. RuboCop includes support for MRI 2.0, 2.1, 2.2, 2.3, 2.4, and 2.5, jRuby in 2.0 mode, and Rubinius 2.0+.

Enable the Plugin

To enable the RuboCop engine for your project, add the following to your .codeclimate.yml configuration file: ‚Äč

  1. Commit a .codeclimate.yml to the root of all branches in your repository.
  2. Add an engines node.
  3. Mark rubocop as enabled: true.
plugins:
  rubocop:
    enabled: true

More information about the CLI is available in the README here: https://github.com/codeclimate/codeclimate

Configure the Plugin

Default configuration

Our Rubocop plugin uses the default configuration found here.

RuboCop supports configuration via a .rubocop.yml configuration file as detailed in RuboCop's documentation. Edit your .rubocop.yml to select rules and tune thresholds that best meet the requirements of your team.

A complete list of available "cops" can be found by scanning the file lists for each cop category:

Using a non-standard configuration file

Some users may want to keep their configuration in a file named something other than .rubocop.yml. You can specify an alternate file name in your .codeclimate.yml:

plugins:
  rubocop:
    enabled: true
    config:
      file: my_rubocop.yml

Using rubocop's newer versions

Newer versions of rubocop can be set up before they are enabled by default. You can specify which channel you want in the .codeclimate.yml:

plugins:
  rubocop:
    enabled: true
    channel: rubocop-0-48

Available channels can be found here.

Using newer versions of RuboCop vs the Rubocop Engine default

You might encounter errors if you rely on Code Climate to infer a RuboCop configuration file for you.

  • To avoid that, be sure to have a version-specific .rubocop.yml in your repo.

Customizing Checks and Thresholds

Users can adjust their RuboCop configuration through a variety of means, including:

  • Directly disable a check in their .codeclimate.yml file:
    plugins:
    rubocop:
      enabled: true
      checks:
        Rubocop/Metrics/ClassLength:
          enabled: false
    
  • Enable and disable rules by specifying Enabled: true or false under Rule name in their .rubocop.yml
  • Comment inline
    • for x in (0..19) # rubocop:disable Style/AvoidFor
  • Configure tolerance for violations (including complexity) by tuning the threshold in their .rubocop.yml under the Rule name. For instance:

RuboCop provides several different metrics which can be used to help assess the maintainability of code, including:

RuboCop