lib/rubocop/config_loader.rb in rubocop-0.48.1 vs lib/rubocop/config_loader.rb in rubocop-0.49.0

- old
+ new

@@ -145,13 +145,11 @@ params.merge('Enabled' => !disabled_by_default) end end if disabled_by_default - config = transform(config) do |params| - { 'Enabled' => true }.merge(params) # Set true if not set. - end + config = handle_disabled_by_default(config, default_configuration) end Config.new(merge(default_configuration, config), config_file) end @@ -161,9 +159,27 @@ hash['AllCops'][version] = hash['AllCops'][version].to_f end private + + def handle_disabled_by_default(config, new_default_configuration) + department_config = config.to_hash.reject { |cop| cop.include?('/') } + department_config.each do |dept, dept_params| + next unless dept_params['Enabled'] + + new_default_configuration.each do |cop, params| + next unless cop.start_with?(dept + '/') + + # Retain original default configuration for cops in the department. + params['Enabled'] = default_configuration[cop]['Enabled'] + end + end + + transform(config) do |params| + { 'Enabled' => true }.merge(params) # Set true if not set. + end + end # Returns a new hash where the parameters of the given config hash have # been replaced by parameters returned by the given block. def transform(config) Hash[config.map { |cop, params| [cop, yield(params)] }]