add check if executable and subcmd are the same before combining
e.g. ˚jrsonnet˚ needs this
This commit is contained in:
parent
cf84800939
commit
02c9cc0720
@ -517,7 +517,14 @@ module RuboCop
|
|||||||
|
|
||||||
return if offenses.blank?
|
return if offenses.blank?
|
||||||
|
|
||||||
T.must(offenses[0...-1]).each do |node|
|
T.must(offenses[0...-1]).each_with_index do |node, i|
|
||||||
|
# executable and subcmd have to be the same to be combined
|
||||||
|
if node.arguments.first != offenses[i + 1].arguments.first ||
|
||||||
|
node.arguments.second != offenses[i + 1].arguments.second
|
||||||
|
shells.delete_at(i)
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
offending_node(node)
|
offending_node(node)
|
||||||
problem "Use a single `generate_completions_from_executable` " \
|
problem "Use a single `generate_completions_from_executable` " \
|
||||||
"call combining all specified shells." do |corrector|
|
"call combining all specified shells." do |corrector|
|
||||||
@ -526,6 +533,8 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return if shells.length <= 1 # no shells to combine left
|
||||||
|
|
||||||
offending_node(offenses.last)
|
offending_node(offenses.last)
|
||||||
replacement = if (%w[:bash :zsh :fish] - shells).empty?
|
replacement = if (%w[:bash :zsh :fish] - shells).empty?
|
||||||
@offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/, "")
|
@offensive_node.source.sub(/shells: \[(:bash|:zsh|:fish)\]/, "")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user