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

Syntax Cop Configuration Error #4932

Closed
chihhungl opened this issue Oct 25, 2017 · 3 comments
Closed

Syntax Cop Configuration Error #4932

chihhungl opened this issue Oct 25, 2017 · 3 comments

Comments

@chihhungl
Copy link

Recently upgraded rubocop to 0.51.0. We have our own rubocop.yml which is inherited from .rubocop.enabled.yml, .rubocop.disabled.yml, and .rubocop.default.yml. Each of them is the same as the enabled.yml, disabled.yml, default.yml in the release 0.51.0.
However, we tried to run rubocop file.rb on command line and we got the following error message.

Error: configuration for Syntax cop found in .rubocop.enabled.yml
This cop cannot be configured.

When we look at the config.rb in the release 0.51.0, it appears that this cop in our .rubocop.enabled.yml fails the validation here in config.rb.
The logic here seems kinda odd: it returns unless the Lint/Syntax or Syntax is included in valid_cop_names, otherwise raise an error. In another word, if Lint/Syntax or Syntax is included in valid_cop_names then raise an error.
Our temporary solution is to comment out Syntax cop.

Steps to reproduce the problem

  1. Upgrade rubocop to 0.51.0

  2. Copy enabled.yml, disabled.yml, and default.yml and rename them to .rubocop.enabled.yml, .rubocop.disabled.yml, and .rubocop.default.yml.

  3. Create a new file name .rubocop.yml with the following content

inherit_from:
  - .rubocop.enabled.yml
  - .rubocop.disabled.yml
  - .rubocop.default.yml
  1. Remove the following block in .rubocop.default.yml to avoid duplicate inheritance.
inherit_from:
  - enabled.yml
  - disabled.yml
  1. run rubocop on an arbitrary file

Expected behavior

It should check that file without exceptions.

Actual behavior

Got the following error

Error: configuration for Syntax cop found in .rubocop.enabled.yml
This cop cannot be configured.

RuboCop version

$ rubocop -V
0.51.0 (using Parser 2.4.0.0, running on ruby 2.3.5 x86_64-darwin16)
@cjlarose
Copy link
Contributor

cjlarose commented Oct 25, 2017

@chihhungl and I ran into this together. To provide a little more context, the project we work on uses HoundCI to run rubocop against our PRs. For old repos, HoundCI runs PRs against their own rubocop config (which is different from rubocop's own default config). You can check in a .rubocop.yml file, but that only overrides their default, not rubocop's default. This is a pain since locally, we don't have Hound's rubocop defaults. Our solution right now is to check in to our repos rubocop's default config files along with what we override.

The problem is that with our recent upgrade to 0.51.0, rubocop's own default config files do not pass rubocop's config validation. We believe this to be a regression introduced by #4466

@akhramov
Copy link

akhramov commented Oct 25, 2017

@pocke, shouldn't we raise an error if the cop is actually configured, i.e. config contains parameters which differ from default ones?

Or, probably, should the error message suggest removing Syntax cop from the config? Current message already describes the problem well, but there's no explanation on how the problem should be resolved.

WDYT?

@pocke
Copy link
Collaborator

pocke commented Oct 26, 2017

Rubocop should raises an error only if the cop is actually configured, right? I agree it. 👍

BTW, I think coping the configuration files from rubocop's config/ is a bad practice.

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

4 participants