Open ustimchik opened 4 years ago
@ustimchik: consider adding this to your .rubocop.yml
:
inherit_mode:
merge:
- Exclude
- Include
AllCops:
Include:
- lib/path/to/your/engines/**/*.rb
@ianyamey, it seems that this config somehow conflicts with rubocop-rails
default config:
Finds 36 Rails/HasAndBelongsToMany
offences
require:
- ./linters/custom_cops.rb
- rubocop-rails
inherit_mode:
merge:
- Exclude
- Include
Still finds 36 Rails/HasAndBelongsToMany
offences
require:
- ./linters/custom_cops.rb
- rubocop-rails
inherit_mode:
merge:
- Exclude
- Include
AllCops:
Include:
- 'plugins/**/*.rb'
Only with specific rule overwrite it finds 50 Rails/HasAndBelongsToMany
offenses and actually applies this rule to plugins/**/*.rb
files
require:
- ./linters/custom_cops.rb
- rubocop-rails
inherit_mode:
merge:
- Exclude
- Include
Rails/HasAndBelongsToMany:
Include:
- 'plugins/**/*.rb'
I'm having this issue as well. It may be more straightforward to include engine paths (ex. engines/**/app/models/**/*
) for the relevant cops in default.yml, instead of adding new config features.
I am also having this issue, not with Engines but with Packwerk, which uses a similar subfolder structure - in my case it looks like packs/**/app/models/**/*
. I'd like to apply the same rubocop config to all of my packs, but when I put this config in a root level .rubocop.yml
, rubocop-rails doesn't apply the model/controller/etc-specific cops to any files within packs.
The only solution I've found so far is to copy my root-level .rubocop.yml
into every single pack directory (packs/**/.rubocop.yml
). This isn't sustainable and I would love to find a better option.
When using engines, the path for controllers, models, etc. are different from the core application which forces gem users to enable "Include" for all cops with this configurable option.
It would be great if there was a possibility to have some configurable global parameters, for instance: