Simplify offending_stanzas method - pass sorted_stanzas in directly
- Otherwise we're doing the same "if inner" check twice, for no gain.
This commit is contained in:
parent
9457a23430
commit
40bc235cb6
@ -36,7 +36,7 @@ module RuboCop
|
|||||||
|
|
||||||
def add_offenses(stanzas, inner: false)
|
def add_offenses(stanzas, inner: false)
|
||||||
sorted_stanzas = inner ? sorted_inner_stanzas(stanzas) : sorted_toplevel_stanzas
|
sorted_stanzas = inner ? sorted_inner_stanzas(stanzas) : sorted_toplevel_stanzas
|
||||||
offending_stanzas(stanzas, inner: inner).each do |stanza|
|
offending_stanzas(stanzas, sorted_stanzas).each do |stanza|
|
||||||
message = format(MESSAGE, stanza: stanza.stanza_name)
|
message = format(MESSAGE, stanza: stanza.stanza_name)
|
||||||
add_offense(stanza.source_range_with_comments, message: message) do |corrector|
|
add_offense(stanza.source_range_with_comments, message: message) do |corrector|
|
||||||
correct_stanza_index = stanzas.index(stanza)
|
correct_stanza_index = stanzas.index(stanza)
|
||||||
@ -47,8 +47,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def offending_stanzas(stanzas, inner: false)
|
def offending_stanzas(stanzas, sorted_stanzas)
|
||||||
sorted_stanzas = inner ? sorted_inner_stanzas(stanzas) : sorted_toplevel_stanzas
|
|
||||||
stanza_pairs = stanzas.zip(sorted_stanzas)
|
stanza_pairs = stanzas.zip(sorted_stanzas)
|
||||||
stanza_pairs.each_with_object([]) do |stanza_pair, offending_stanzas|
|
stanza_pairs.each_with_object([]) do |stanza_pair, offending_stanzas|
|
||||||
stanza, sorted_stanza = *stanza_pair
|
stanza, sorted_stanza = *stanza_pair
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user