How do I get a rubocop to show the severity of the warning or worse?

I have a large legacy codebase and want to start working on warnings. How can I get rubocop to just show me warnings (lines starting with W :) and worse, and suppress all conventions (lines starting with C :)?

+3


source to share


1 answer


I found that rubocop breaks rules into different categories : , and others : Syntax

Lint

If you don't have custom severity levels in your configuration, it's pretty straightforward. Sinax Cop reports fatal and erroneous level, Lint policies at warning level and all other cops at agreement level.

So, for fatal and error only, this rubocop --only Syntax

(which is only maintained by the master, not yet released) for both warning and above rubocop --only Lint

.

Therefore, these are the errors Lint

that I need to fix first.



In my case, the best way to handle this is to work from top to bottom through rubocop_todo.yml

, which can be created with

rubocop --auto-gen-config

Since the file rubocop_todo.yml

is created in order of severity, i.e. Syntax

at the top and then Lint

and then others, working through them in order, first captures the warnings.

+5


source







All Articles