brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2021-07-12 18:08:06 +00:00
parent 6750f97a4f
commit d0fea51e8b
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
107 changed files with 20 additions and 24 deletions

View File

@ -83,7 +83,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.0.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.18.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.4/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.11.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.11.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.1/lib"

View File

@ -57,12 +57,13 @@ module RuboCop
# Resolve relation into column name.
# It just returns column_name if the column exists.
# Or it tries to resolve column_name as a relation.
# Returns an array of column names if the relation is polymorphic.
# It returns `nil` if it can't resolve.
#
# @param name [String]
# @param class_node [RuboCop::AST::Node]
# @param table [RuboCop::Rails::SchemaLoader::Table]
# @return [String, nil]
# @return [Array, String, nil]
def resolve_relation_into_column(name:, class_node:, table:)
return unless table
return name if table.with_column?(name: name)
@ -71,7 +72,9 @@ module RuboCop
next unless belongs_to.first_argument.value.to_s == name
fk = foreign_key_of(belongs_to) || "#{name}_id"
return fk if table.with_column?(name: fk)
next unless table.with_column?(name: fk)
return polymorphic?(belongs_to) ? [fk, "#{name}_type"] : fk
end
nil
end
@ -88,6 +91,15 @@ module RuboCop
end
end
def polymorphic?(belongs_to)
options = belongs_to.last_argument
return false unless options.hash_type?
options.each_pair.any? do |pair|
pair.key.sym_type? && pair.key.value == :polymorphic && pair.value.true_type?
end
end
def in_where?(node)
send_node = node.each_ancestor(:send).first
send_node && WHERE_METHODS.include?(send_node.method_name)

View File

@ -71,7 +71,7 @@ module RuboCop
# Autocorrect by swapping between two nodes autocorrecting them
def autocorrect(corrector, node)
previous = left_siblings_of(node).reverse_each.find do |sibling|
previous = node.left_siblings.reverse_each.find do |sibling|
callback?(sibling)
end
@ -96,14 +96,6 @@ module RuboCop
node.send_type? && CALLBACKS_ORDER_MAP.key?(node.method_name)
end
def left_siblings_of(node)
siblings_of(node)[0, node.sibling_index]
end
def siblings_of(node)
node.parent.children
end
def source_range_with_comment(node)
begin_pos = begin_pos_with_comment(node)
end_pos = end_position_for(node)

View File

@ -56,8 +56,8 @@ module RuboCop
def register_offense(allow_nil, message)
add_offense(allow_nil, message: message) do |corrector|
prv_sib = previous_sibling(allow_nil)
nxt_sib = next_sibling(allow_nil)
prv_sib = allow_nil.left_sibling
nxt_sib = allow_nil.right_sibling
if nxt_sib
corrector.remove(range_between(node_beg(allow_nil), node_beg(nxt_sib)))
@ -88,14 +88,6 @@ module RuboCop
nil
end
def previous_sibling(node)
node.parent.children[node.sibling_index - 1]
end
def next_sibling(node)
node.parent.children[node.sibling_index + 1]
end
def node_beg(node)
node.loc.expression.begin_pos
end

View File

@ -81,7 +81,7 @@ module RuboCop
names_from_scope = column_names_from_scope(node)
ret.concat(names_from_scope) if names_from_scope
ret.map! do |name|
ret = ret.flat_map do |name|
klass = class_node(node)
resolve_relation_into_column(
name: name.to_s,

Some files were not shown because too many files have changed in this diff Show More