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

Merged

Conversation

Projects
None yet
2 participants
@hoshinotsuyoshi
Copy link
Contributor

commented Apr 30, 2019

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

https://github.com/rubocop-hq/rubocop/blob/v0.68.0/lib/rubocop/config.rb#L545-L550


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
   SupportedStyles:
     - 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
..F...............

Failures:

  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?

     RuntimeError:
       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.
Add a validation for RuboCop's config/default.yml for supported style…
…s other than EnforcedStyle

This is almost same validation to RuboCop::Config#validate_enforced_styles.
https://github.com/rubocop-hq/rubocop/blob/v0.68.0/lib/rubocop/config.rb#L545-L550

@bbatsov bbatsov merged commit dea47fb into rubocop-hq:master Apr 30, 2019

25 checks passed

ci/circleci: cc-setup Your tests passed on CircleCI!
Details
ci/circleci: cc-upload-coverage Your tests passed on CircleCI!
Details
ci/circleci: documentation-checks Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-spec Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@bbatsov

This comment has been minimized.

Copy link
Collaborator

commented Apr 30, 2019

Thanks!

@hoshinotsuyoshi hoshinotsuyoshi deleted the hoshinotsuyoshi: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
You can’t perform that action at this time.