Question
Is it possible to tell Rubocop to return 0
as exit code when only warnings are found?
Prerequisites
I am using the following command to run Rubocop on Travis CI:
bundle exec rubocop
I have a cop which is configured as a warning in
rubocop.yml
:Style/Documentation: Severity: warning
Problem
Travis CI treats a command as a successful one only if its exit code is equal to 0
.
Rubocop returns 0
as exit code when it finds no offences,
but when it finds at least one offence,
it returns 1
as exit code, no matter whether this offence is an error or a warning.
As a result, Travis CI builds are failed when only warnings are found by Rubocop.
Therefore, is it possible to tell Rubocop to return 0
as exit code when only warnings are found?
Thanks in advance.
Notes
Please, do NOT suggest to disable cops.
I am using the following approach to check exit codes:
$ bundle exec rubocop // ... 14 files inspected, 8 offenses detected $ echo "$?" 1