lib/scss_lint/config.rb in scss_lint-0.55.0 vs lib/scss_lint/config.rb in scss_lint-0.56.0
- old
+ new
@@ -62,11 +62,11 @@
if yaml = YAML.load(file_contents)
yaml.to_hash
else
{}
end
- rescue => ex
+ rescue StandardError => ex
raise SCSSLint::Exceptions::InvalidConfiguration,
"Invalid configuration: #{ex.message}"
end
options = convert_single_options_to_arrays(options)
@@ -93,16 +93,19 @@
# Merge options from wildcard linters into individual linter configs
def merge_wildcard_linter_options(options)
options = options.dup
+ # rubocop:disable Performance/HashEachMethods (FALSE POSITIVE)
+ # Cannot use `each_key` because the cycle adds new keys during iteration
options.fetch('linters', {}).keys.each do |class_name|
next unless class_name.include?('*')
wildcard_options = options['linters'].delete(class_name)
apply_options_to_matching_linters(class_name, options, wildcard_options)
end
+ # rubocop:enable Performance/HashEachMethods
options
end
def apply_options_to_matching_linters(class_name_glob, current_options, linter_options)
@@ -122,11 +125,11 @@
def ensure_linter_exclude_paths_are_absolute(options, original_file)
options = options.dup
options['linters'] ||= {}
- options['linters'].keys.each do |linter_name|
+ options['linters'].each_key do |linter_name|
options['linters'][linter_name] =
ensure_exclude_paths_are_absolute(options['linters'][linter_name], original_file)
end
options
@@ -262,11 +265,11 @@
def disable_linter(linter)
linter_options(linter)['enabled'] = false
end
def disable_all_linters
- @options['linters'].values.each do |linter_config|
+ @options['linters'].each_value do |linter_config|
linter_config['enabled'] = false
end
end
def linter_options(linter)
@@ -314,10 +317,10 @@
private
def validate_linters
return unless linters = @options['linters']
- linters.keys.each do |name|
+ linters.each_key do |name|
begin
Linter.const_get(name)
rescue NameError
@warnings << "Linter #{name} does not exist; ignoring"
end