Forrest logo
back to the rubocop tool

rubocop:tldr:77137

rubocop: Run only specified cops.
$ rubocop --only ${cop_1} ${cop_2}
try on your machine

The command you provided, "rubocop --only ${cop_1} ${cop_2}", is used to run the RuboCop tool with specific cops (linting rules) enabled for analysis.

Here's a breakdown of the command:

  • "rubocop": This is the command to run the RuboCop tool, which is a popular static code analyzer and formatter for Ruby code.
  • "--only": This option is used to specify that only specific cops should be enabled for analysis. It restricts RuboCop to examine and report only the selected cops.
  • "${cop_1} ${cop_2}": These are placeholders for the names of the specific cops (linting rules) that you want RuboCop to analyze. You need to replace ${cop_1} and ${cop_2} with the actual names of the cops you want to enable. For example, if you have two cops named "Layout/Indentation" and "Naming/ConsistentNaming", the command would look like: "rubocop --only Layout/Indentation Naming/ConsistentNaming".

By providing specific cops to the --only option, you can narrow down the analysis to focus on the particular aspects of your code that these cops address. This can be helpful if you want to prioritize certain rules or if you have specific preferences for code style and conventions.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the rubocop tool