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 unset_nil option to ConfigLoader.merge_with_default #7048

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/rubocop/config_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def default_configuration
# If AllCops::EnabledByDefault is true, it changes the Enabled params
# so that only cops explicitly disabled in user configuration are
# disabled.
def merge_with_default(config, config_file)
resolver.merge_with_default(config, config_file)
def merge_with_default(config, config_file, unset_nil: true)
resolver.merge_with_default(config, config_file, unset_nil: unset_nil)
end

def add_inheritance_from_auto_generated_file
Expand Down
5 changes: 3 additions & 2 deletions lib/rubocop/config_loader_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def resolve_inheritance_from_gems(hash, gems)
# only cops from user configuration are enabled. If
# AllCops::EnabledByDefault is true, it changes the Enabled params so that
# only cops explicitly disabled in user configuration are disabled.
def merge_with_default(config, config_file)
def merge_with_default(config, config_file, unset_nil:)
default_configuration = ConfigLoader.default_configuration

disabled_by_default = config.for_all_cops['DisabledByDefault']
Expand All @@ -71,7 +71,8 @@ def merge_with_default(config, config_file)
config = handle_disabled_by_default(config, default_configuration)
end

opts = { inherit_mode: config['inherit_mode'] || {}, unset_nil: true }
opts = { inherit_mode: config['inherit_mode'] || {},
unset_nil: unset_nil }
Config.new(merge(default_configuration, config, opts), config_file)
end

Expand Down