Merge pull request #4396 from Homebrew/dep-order-cop-fix

DependencyOrder: Fix var initialization bug
This commit is contained in:
Gautham Goli 2018-06-30 19:02:04 +05:30 committed by GitHub
commit fac11c2f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,9 +58,8 @@ module RuboCop
ordered.each_with_index do |dep, pos| ordered.each_with_index do |dep, pos|
idx = pos+1 idx = pos+1
match_nodes = build_with_dependency_name(dep) match_nodes = build_with_dependency_name(dep)
idx1 = pos if match_nodes && !match_nodes.empty? next if !match_nodes || match_nodes.empty?
next unless idx1 idx1 = pos
idx2 = nil
ordered.drop(idx1+1).each_with_index do |dep2, pos2| ordered.drop(idx1+1).each_with_index do |dep2, pos2|
next unless match_nodes.index(dependency_name(dep2)) next unless match_nodes.index(dependency_name(dep2))
idx2 = pos2 if idx2.nil? || pos2 > idx2 idx2 = pos2 if idx2.nil? || pos2 > idx2