summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2019-09-06 14:57:10 +0200
committerChristian Couder <chriscool@tuxfamily.org>2019-09-07 17:31:23 +0200
commit4aa4449ef5109eb0784f63fe1b7a3fc15bea8497 (patch)
tree5716f462ad2715d41739a9c8cbd530b07f0f2c83
parentec326ecf91e893531bc2412fd4177405911e0e98 (diff)
downloadgitlab-ce-4aa4449ef5109eb0784f63fe1b7a3fc15bea8497.tar.gz
Refactor parse_options() in push_options.rbreduce-parse-options-complexity
This improves code quality by reducing Cognitive Complexity. This fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/67091
-rw-r--r--lib/gitlab/push_options.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/gitlab/push_options.rb b/lib/gitlab/push_options.rb
index a2296d265cd..93c0f3132d0 100644
--- a/lib/gitlab/push_options.rb
+++ b/lib/gitlab/push_options.rb
@@ -56,19 +56,23 @@ module Gitlab
next if [namespace, key].any?(&:nil?)
- 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
+ store_option_info(options, namespace, key, value)
end
options
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)
MULTI_VALUE_OPTIONS.any? { |arr| arr == [namespace, key] }
end