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

Add a validation for RuboCop's own config/default.yml for supported styles other than EnforcedStyle #7005



Copy link

@hoshinotsuyoshi hoshinotsuyoshi commented Apr 30, 2019

I added same validation to RuboCop::Config#validate_enforced_styles.

If accidentally typos committed,

--- a/config/default.yml
+++ b/config/default.yml
@@ -211,7 +211,7 @@ Layout/AccessModifierIndentation:
   StyleGuide: '#indent-public-private-protected'
   Enabled: true
   VersionAdded: '0.49'
-  EnforcedStyle: indent
+  EnforcedStyle: indenttttttttt
     - outdent
     - indent

CI will fail.

$ bundle exec rspec spec/project_spec.rb
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 2116


  1) RuboCop Project default configuration file has a SupportedStyles for all EnforcedStyle and EnforcedStyle is valid
     Failure/Error: raise errors.join("\n") unless errors.empty?

       invalid EnforcedStyle 'indenttttttttt' for Layout/AccessModifierIndentation found
     # ./spec/project_spec.rb:56:in `block (3 levels) in <top (required)>'

Finished in 1.36 seconds (files took 1.28 seconds to load)
18 examples, 1 failure

Failed examples:

rspec ./spec/project_spec.rb:37 # RuboCop Project default configuration file has a SupportedStyles for all EnforcedStyle and EnforcedStyle is valid

Randomized with seed 2116

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.
…s other than EnforcedStyle

This is almost same validation to RuboCop::Config#validate_enforced_styles.
@bbatsov bbatsov merged commit dea47fb into rubocop:master Apr 30, 2019
25 checks passed
Copy link

@bbatsov bbatsov commented Apr 30, 2019


@hoshinotsuyoshi hoshinotsuyoshi deleted the detect_missing_supported_styles branch May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants