Skip to content

Commit

Permalink
Add a validation for RuboCop's config/default.yml for supported style…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
hoshinotsuyoshi authored and bbatsov committed Apr 30, 2019
1 parent a242d4a commit dea47fb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/project_spec.rb
Expand Up @@ -40,10 +40,16 @@
cop_names.each do |name|
enforced_styles = config[name]
.select { |key, _| key.start_with?('Enforced') }
enforced_styles.each_key do |style_name|
enforced_styles.each do |style_name, style|
supported_key = RuboCop::Cop::Util.to_supported_styles(style_name)
valid = config[name][supported_key]
errors.push("#{supported_key} is missing for #{name}") unless valid
unless valid
errors.push("#{supported_key} is missing for #{name}")
next
end
next if valid.include?(style)

errors.push("invalid #{style_name} '#{style}' for #{name} found")
end
end

Expand Down

0 comments on commit dea47fb

Please sign in to comment.