Rubocop: Don't let RuboCop blow up when removing `.rubocop_todo.yml`

Created on 10 Aug 2016  路  8Comments  路  Source: rubocop-hq/rubocop

Running bundle exec rubocop --auto-gen-config will edit .rubocop.yml to inherit from .rubocop_todo.yml. If the latter is removed, subsequently running bundle exec rubocop will result in an unhandled exception.

I think we should emit a warning instead, or worst case exit with an appropriate message.


Expected behavior

Warning: inherited configuration `.rubocop_todo.yml` not found.

(RuboCop continues to run.)

Actual behavior

No such file or directory @ rb_sysopen - /Users/drenmi/Workspace/Rubocop/rubocop/.rubocop_todo.yml

Steps to reproduce the problem

  1. Run bundle exec rubocop --auto-gen-config
  2. Delete the generated .rubocop_todo.yml
  3. Run bundle exec rubocop

    RuboCop version

Include the output of rubocop -V:

$ rubocop -V
0.42.0 (using Parser 2.3.1.2, running on ruby 2.3.0 x86_64-darwin15)
enhancement

Most helpful comment

Something has changed on current master that requires you to manually add the inherit_from to the configuration file.

As far as I know, it's always been like that.

:+1: on failing with an error message pointing to the unsuccessful inherit_from.

All 8 comments

Maybe still make it fail with a more clear error message unless the user is running with --auto-gen-config? Only issuing a warning will probably result in more confusion if all of the sudden rubocop is complaining about a bunch of violations that were previously suppressed

Yeah. I'm okay with that too. 馃榾

I couldn't reproduce the problem.
Rubocop Version
0.42.0 (using Parser 2.3.1.2, running on ruby 2.2.4 x86_64-darwin15)

Steps Followed

  1. Run bundle exec rubocop --auto-gen-config
  2. Delete the generated .rubocop_todo.yml
  3. Run bundle exec rubocop

Tried with ruby 2.3.0 as well.

@absk1317: Something has changed on current master that requires you to manually add the inherit_from to the configuration file.

As evidenced by the message when running bundle exec rubocop --auto-gen-config:

Run rubocop --config .rubocop_todo.yml, or add inherit_from: .rubocop_todo.yml in a .rubocop.yml file.

Something has changed on current master that requires you to manually add the inherit_from to the configuration file.

As far as I know, it's always been like that.

:+1: on failing with an error message pointing to the unsuccessful inherit_from.

Given that this has been approved by Jonas, I'd be happy to work on it, unless anyone else already is?

@jaredbeck: Feel free to have a go at it. Would love to see this in place. 馃檪

Was this page helpful?
0 / 5 - 0 ratings

Related issues

printercu picture printercu  路  3Comments

benoittgt picture benoittgt  路  3Comments

Ana06 picture Ana06  路  3Comments

AndreiMotinga picture AndreiMotinga  路  3Comments

NobodysNightmare picture NobodysNightmare  路  3Comments