Skip to content
New issue

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

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

Already on GitHub? # to your account

Rubocop doesn't show the cop name in guard-rubocop but it does on the CLI #42

Open
coaxial opened this issue Nov 22, 2019 · 3 comments
Open

Comments

@coaxial
Copy link

coaxial commented Nov 22, 2019

Compare:

$ bundle exec rubocop
Inspecting 14 files
............W.

Offenses:

spec/my_spec.rb:42:1: W: Lint/MissingCopEnableDirective: Re-enable Lint/HandleExceptions cop with # rubocop:enable after disabling it.
        # rescue SystemExit # rubocop:disable Lint/HandleExceptions
^
spec/my_spec.rb:43:26: C: Layout/TrailingWhitespace: Trailing whitespace detected.
        rescue SystemExit
                         ^

14 files inspected, 2 offenses detected

with

$ bundle exec guard
08:02:31 - INFO - Guard::RSpec is running
08:02:31 - INFO - Inspecting Ruby code style of all files
Inspecting 14 files
............W.

Offenses:

spec/my_spec.rb:42:1: W: Re-enable Lint/HandleExceptions cop with # rubocop:enable after disabling it.
        # rescue SystemExit # rubocop:disable Lint/HandleExceptions
^
spec/my_spec.rb:43:26: C: Trailing whitespace detected.
        rescue SystemExit
                         ^

When running guard-rubocop, the name of the cop that matches the lint error isn't written. But it is when running rubocop directly. I have no options set on my guard:

guard :rubocop do
  watch('Gemfile')
  watch('Rakefile')
  watch(/.+\.rb$/)
  watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
end
@griley
Copy link

griley commented Mar 12, 2020

@coaxial , try

guard :rubocop, cli: ['--display-cop-names']`  do
  ...
end

@barelyknown
Copy link

Does anyone know why the command line option is required instead of the .rubocop.yml (AllCops/DisplayCopNames: true)?

@kassi
Copy link

kassi commented May 20, 2024

@barelyknown One thing is that guard-rubocop does not run rubocop with bundler and you can't simply add cmd: "bundle exec rubocop" to Guardfile nor cmd: %w[bundle exec rubocop] without a change in the gem (see #55).
In addition, it then only works if you pass cli: "--config .rubocop.yml" to the guard. Couldn't figure out yet, why this is the case.

edit: at least it did it after I changed that. Now it's kinda back to where it was before.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants