How do I get rubocop to show severities of Warning or worse only?

I discovered that rubocop splits the rules into different categories: Syntax, Lint and others:

If you don't have any custom severity levels in your configuration, it's quite simple. The Synax cop reports on fatal and error level, Lint cops on warning level and all other cops on convention level.

So for only fatal and error, it's rubocop --only Syntax (which is only supported on master, not released yet), and for warning and above it's rubocop --only Lint.

Therefore it's the Lint errors that I need to fix first.

In my case the best way to handle this was to work top to bottom through the rubocop_todo.yml which can be created with:

rubocop --auto-gen-config

Since the rubocop_todo.yml file is created in order of severity ie Syntax ones at the top, followed by Lint, followed by others, working through them in order fixes the warnings first.


Utilize the --display-only-fail-level-offenses flag and set the fail-level to warning:

rubocop --fail-level warning --display-only-fail-level-offenses

Tags:

Rubocop