Language / Framework: Ruby
Categories: Complexity, Security, Clarity, Performance, Bug Risk, Style
RuboCop Version: 0.52.1 (other versions including RuboCop 0.58.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+.
To enable the RuboCop engine for your project, add the following to your .codeclimate.yml configuration file:
- Commit a
.codeclimate.ymlto the root of all branches in your repository.
- Add an
rubocopas enabled: true.
plugins rubocop enabledtrue
More information about the CLI is available in the README here: https://github.com/codeclimate/codeclimate
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:
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
plugins rubocop enabledtrue config filemy_rubocop.yml
Newer versions of rubocop can be set up before they are enabled by default. You can specify which
channel you want in the
plugins rubocop enabledtrue channelrubocop-0-60
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.
Users can adjust their RuboCop configuration through a variety of means, including:
- Directly disable a check in their
plugins: rubocop: enabled: true checks: Rubocop/Metrics/ClassLength: enabled: false
- Enable and disable rules by specifying
falseunder Rule name in their
- Comment inline
for x in (0..19) # rubocop:disable Style/AvoidFor
- Configure tolerance for violations (including complexity) by tuning the threshold in their
.rubocop.ymlunder the Rule name. For instance:
RuboCop provides several different metrics which can be used to help assess the maintainability of code, including: