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

Hound fails to merge RuboCop configuration properly #1842

Open
skalee opened this issue Apr 29, 2021 · 2 comments
Open

Hound fails to merge RuboCop configuration properly #1842

skalee opened this issue Apr 29, 2021 · 2 comments

Comments

@skalee
Copy link

skalee commented Apr 29, 2021

Hound inherits organization-wide Ruby style book in a different way than RuboCop.

Given organization-wide .rubocop.yml

Metrics/MethodLength:
  Description: Avoid methods longer than 10 lines of code.
  Max: 10

and project-specific .rubocop.yml:

# This is for locally installed RuboCop. Hound ignores it.
inherit_from:
  - https://raw.githubusercontent.com/path/to/organization-wide/.rubocop.yml

Metrics:
  Enabled: false

Hound reports violations of Metrics/MethodLength, whereas local RuboCop does not (cop is disabled as expected). IMO Hound's behaviour is incorrect.

RuboCop 1.5.2 in both cases.

@skalee
Copy link
Author

skalee commented Apr 29, 2021

This is because Hound simply merges organization-wide configuration into project-specific one, instead of relying on RuboCop's inheritance rules:

inherited_config.deep_merge(config.except("inherit_from"))

@skalee
Copy link
Author

skalee commented Apr 29, 2021

To clarify: It isn't a problem when overriding specific cop, but it is a problem when overriding the whole department. Due to incorrect merging, more specific Metrics/MethodLength takes precedence over Metrics. That would be correct if they were set in the same file. But they are not, hence Metrics should take precedence over Metrics/MethodLength, as the latter is defined in the inherited style book.

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

No branches or pull requests

1 participant