solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

Rubocop extra_args not being picked up

Open dgmora opened this issue 2 years ago • 4 comments

I may be doing something wrong, but I've tried with the following config:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require:
  - actioncable
  - actionmailer
  - actionpack
  - actionview
  - activejob
  - activemodel
  - activerecord
  - activestorage
  - activesupport
domains: []
reporters:
- rubocop
formatter:
  rubocop:
    cops: all
    except:
      - 'RSpec/Focus'
    only: []
    extra_args:
      - '-D'
      - '--config'
      - '.rubocop.local.yml'
require_paths: []
plugins: []
max_files: 5000

extra_args does not seem to pick up -D (to show the cop name), it only shows the error message. --config also does not seem to work, it's picking up rubocop.yml instead of rubocop.local.yml. Are the extra args specified incorrectly?

dgmora avatar Sep 30 '21 07:09 dgmora

It sounds like your concern is with problem descriptions in the diagnostics display. The RuboCop diagnostics reporter should display the cop name by default:

image

The options under formatter only apply to formatting, not diagnostics. That was a deliberate choice due to cases where the formatter needs additional arguments that the reporter doesn't (see #403). I might be able to add support for reporter options in the future, if that's what you need. In the meantime, one possible workaround is to create a .rubocop.yml file that includes .rubocop.local.yml, e.g.:

inherit_from: ./.rubocop.local.yml

castwide avatar Oct 01 '21 03:10 castwide

The cops don't appear in the diagnostics, but that might have to do with my vim configuration. The formatter still doesn't seem to accept the --config flag, it formats based on rubocop.yml

dgmora avatar Oct 01 '21 06:10 dgmora

I'm not seeing the cop name in my diagnostics either and I am not sure where to look to figure this out. Can we get a hint?

hjw avatar Nov 01 '21 18:11 hjw

I'm not seeing the cop name in my diagnostics either and I am not sure where to look to figure this out. Can we get a hint?

I assume the editor doesn't display the source and/or code parameters of the Diagnostics in the textDocument/publishDiagnostics notification. If there's a way you can log the server messages, you should be able to see them there. For the RuboCop reporter. the source is always "rubocop" and the code is the name of the cop (e.g., "Layout/EndOfLine").

castwide avatar Nov 18 '21 22:11 castwide