Commit a4a13235 authored by Peter Leitzen's avatar Peter Leitzen

Reuse already known flag_arg in Gitlab/MarkUsedFeatureFlags

parent 577be505
...@@ -80,7 +80,7 @@ module RuboCop ...@@ -80,7 +80,7 @@ module RuboCop
flag_value = flag_value(node) flag_value = flag_value(node)
return unless flag_value return unless flag_value
if flag_arg_is_str_or_sym?(node) if flag_arg_is_str_or_sym?(flag_arg)
if caller_is_feature_gitaly?(node) if caller_is_feature_gitaly?(node)
save_used_feature_flag("gitaly_#{flag_value}") save_used_feature_flag("gitaly_#{flag_value}")
else else
...@@ -95,9 +95,9 @@ module RuboCop ...@@ -95,9 +95,9 @@ module RuboCop
save_used_feature_flag(matching_feature_flag) save_used_feature_flag(matching_feature_flag)
end end
end end
elsif flag_arg_is_send_type?(node) elsif flag_arg_is_send_type?(flag_arg)
puts_if_ci(node, "Feature flag is dynamic: '#{flag_value}.") puts_if_ci(node, "Feature flag is dynamic: '#{flag_value}.")
elsif flag_arg_is_dstr_or_dsym?(node) elsif flag_arg_is_dstr_or_dsym?(flag_arg)
str_prefix = flag_arg.children[0] str_prefix = flag_arg.children[0]
rest_children = flag_arg.children[1..] rest_children = flag_arg.children[1..]
...@@ -170,18 +170,16 @@ module RuboCop ...@@ -170,18 +170,16 @@ module RuboCop
end.to_s.tr("\n/", ' _') end.to_s.tr("\n/", ' _')
end end
def flag_arg_is_str_or_sym?(node) def flag_arg_is_str_or_sym?(flag_arg)
flag_arg = flag_arg(node)
flag_arg.str_type? || flag_arg.sym_type? flag_arg.str_type? || flag_arg.sym_type?
end end
def flag_arg_is_send_type?(node) def flag_arg_is_send_type?(flag_arg)
flag_arg(node).send_type? flag_arg.send_type?
end end
def flag_arg_is_dstr_or_dsym?(node) def flag_arg_is_dstr_or_dsym?(flag_arg)
flag = flag_arg(node) (flag_arg.dstr_type? || flag_arg.dsym_type?) && flag_arg.children[0].str_type?
(flag.dstr_type? || flag.dsym_type?) && flag.children[0].str_type?
end end
def caller_is_feature?(node) def caller_is_feature?(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment