Language / Framework: Ruby
Categories: Complexity, Security, Clarity, Performance, Bug Risk, Style
RuboCop Version: 0.52.1 (other versions including RuboCop 1.48.1 available by channels)
Our RuboCop plugin provides style and quality checks for Ruby code. RuboCop includes support for MRI 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 and 2.6, jRuby in 2.0 mode, and Rubinius 2.0+.
A fix in the beta channel was recently implemented, removing a gem that prevented some cops from working correctly. If you experience a sudden uptick in reported issues by the engine, be aware that this might be the cause.
To enable the RuboCop plugin 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: enabled: true
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: enabled: true config: file: my_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: enabled: true channel: rubocop-0-79
Available channels can be found here.
Using newer versions of RuboCop vs the Rubocop Plugin 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:
Updated 9 months ago