Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't let RuboCop blow up when removing .rubocop_todo.yml #3396

Closed
Drenmi opened this issue Aug 10, 2016 · 8 comments
Closed

Don't let RuboCop blow up when removing .rubocop_todo.yml #3396

Drenmi opened this issue Aug 10, 2016 · 8 comments

Comments

@Drenmi
Copy link
Collaborator

Drenmi commented Aug 10, 2016

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)
@backus
Copy link
Contributor

backus commented Aug 11, 2016

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

@Drenmi
Copy link
Collaborator Author

Drenmi commented Aug 12, 2016

Yeah. I'm okay with that too. 😀

@absk1317
Copy link

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.

@Drenmi
Copy link
Collaborator Author

Drenmi commented Aug 22, 2016

@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.

@jonas054
Copy link
Collaborator

jonas054 commented Oct 7, 2016

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.

👍 on failing with an error message pointing to the unsuccessful inherit_from.

@jaredbeck
Copy link
Contributor

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

@Drenmi
Copy link
Collaborator Author

Drenmi commented Oct 30, 2017

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

@jaredbeck
Copy link
Contributor

Fixed by #4972

jaredbeck added a commit to jaredbeck/rubocop that referenced this issue Oct 31, 2017
Instead of a stack trace, prints a friendly (concise) message
to stderr when a configuration file, e.g. inherit_from, cannot
be found.

We use the constant Errno::ENOENT because it is present on
all major operating systems. According to the ruby documenation,
there may be some odd platforms that do not support this standard.
If we find that someone is using rubocop on such a platform, we
can rescue SystemCallError instead, but that will make it hard
to exit with the correct exit code.
@bbatsov bbatsov closed this as completed in 2d76341 Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants