Refactor parse_options() in push_options.rb
This improves code quality by reducing Cognitive Complexity. This fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/67091
This commit is contained in:
parent
ec326ecf91
commit
4aa4449ef5
|
@ -56,19 +56,23 @@ module Gitlab
|
||||||
|
|
||||||
next if [namespace, key].any?(&:nil?)
|
next if [namespace, key].any?(&:nil?)
|
||||||
|
|
||||||
options[namespace] ||= HashWithIndifferentAccess.new
|
store_option_info(options, namespace, key, value)
|
||||||
|
|
||||||
if option_multi_value?(namespace, key)
|
|
||||||
options[namespace][key] ||= HashWithIndifferentAccess.new(0)
|
|
||||||
options[namespace][key][value] += 1
|
|
||||||
else
|
|
||||||
options[namespace][key] = value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def store_option_info(options, namespace, key, value)
|
||||||
|
options[namespace] ||= HashWithIndifferentAccess.new
|
||||||
|
|
||||||
|
if option_multi_value?(namespace, key)
|
||||||
|
options[namespace][key] ||= HashWithIndifferentAccess.new(0)
|
||||||
|
options[namespace][key][value] += 1
|
||||||
|
else
|
||||||
|
options[namespace][key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def option_multi_value?(namespace, key)
|
def option_multi_value?(namespace, key)
|
||||||
MULTI_VALUE_OPTIONS.any? { |arr| arr == [namespace, key] }
|
MULTI_VALUE_OPTIONS.any? { |arr| arr == [namespace, key] }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue