brew vendor-gems: commit updates.
This commit is contained in:
parent
6750f97a4f
commit
d0fea51e8b
@ -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/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-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-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-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/rubocop-sorbet-0.6.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.1/lib"
|
||||||
|
|||||||
@ -57,12 +57,13 @@ module RuboCop
|
|||||||
# Resolve relation into column name.
|
# Resolve relation into column name.
|
||||||
# It just returns column_name if the column exists.
|
# It just returns column_name if the column exists.
|
||||||
# Or it tries to resolve column_name as a relation.
|
# 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.
|
# It returns `nil` if it can't resolve.
|
||||||
#
|
#
|
||||||
# @param name [String]
|
# @param name [String]
|
||||||
# @param class_node [RuboCop::AST::Node]
|
# @param class_node [RuboCop::AST::Node]
|
||||||
# @param table [RuboCop::Rails::SchemaLoader::Table]
|
# @param table [RuboCop::Rails::SchemaLoader::Table]
|
||||||
# @return [String, nil]
|
# @return [Array, String, nil]
|
||||||
def resolve_relation_into_column(name:, class_node:, table:)
|
def resolve_relation_into_column(name:, class_node:, table:)
|
||||||
return unless table
|
return unless table
|
||||||
return name if table.with_column?(name: name)
|
return name if table.with_column?(name: name)
|
||||||
@ -71,7 +72,9 @@ module RuboCop
|
|||||||
next unless belongs_to.first_argument.value.to_s == name
|
next unless belongs_to.first_argument.value.to_s == name
|
||||||
|
|
||||||
fk = foreign_key_of(belongs_to) || "#{name}_id"
|
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
|
end
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
@ -88,6 +91,15 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
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)
|
def in_where?(node)
|
||||||
send_node = node.each_ancestor(:send).first
|
send_node = node.each_ancestor(:send).first
|
||||||
send_node && WHERE_METHODS.include?(send_node.method_name)
|
send_node && WHERE_METHODS.include?(send_node.method_name)
|
||||||
@ -71,7 +71,7 @@ module RuboCop
|
|||||||
|
|
||||||
# Autocorrect by swapping between two nodes autocorrecting them
|
# Autocorrect by swapping between two nodes autocorrecting them
|
||||||
def autocorrect(corrector, node)
|
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)
|
callback?(sibling)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -96,14 +96,6 @@ module RuboCop
|
|||||||
node.send_type? && CALLBACKS_ORDER_MAP.key?(node.method_name)
|
node.send_type? && CALLBACKS_ORDER_MAP.key?(node.method_name)
|
||||||
end
|
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)
|
def source_range_with_comment(node)
|
||||||
begin_pos = begin_pos_with_comment(node)
|
begin_pos = begin_pos_with_comment(node)
|
||||||
end_pos = end_position_for(node)
|
end_pos = end_position_for(node)
|
||||||
@ -56,8 +56,8 @@ module RuboCop
|
|||||||
|
|
||||||
def register_offense(allow_nil, message)
|
def register_offense(allow_nil, message)
|
||||||
add_offense(allow_nil, message: message) do |corrector|
|
add_offense(allow_nil, message: message) do |corrector|
|
||||||
prv_sib = previous_sibling(allow_nil)
|
prv_sib = allow_nil.left_sibling
|
||||||
nxt_sib = next_sibling(allow_nil)
|
nxt_sib = allow_nil.right_sibling
|
||||||
|
|
||||||
if nxt_sib
|
if nxt_sib
|
||||||
corrector.remove(range_between(node_beg(allow_nil), node_beg(nxt_sib)))
|
corrector.remove(range_between(node_beg(allow_nil), node_beg(nxt_sib)))
|
||||||
@ -88,14 +88,6 @@ module RuboCop
|
|||||||
nil
|
nil
|
||||||
end
|
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)
|
def node_beg(node)
|
||||||
node.loc.expression.begin_pos
|
node.loc.expression.begin_pos
|
||||||
end
|
end
|
||||||
@ -81,7 +81,7 @@ module RuboCop
|
|||||||
names_from_scope = column_names_from_scope(node)
|
names_from_scope = column_names_from_scope(node)
|
||||||
ret.concat(names_from_scope) if names_from_scope
|
ret.concat(names_from_scope) if names_from_scope
|
||||||
|
|
||||||
ret.map! do |name|
|
ret = ret.flat_map do |name|
|
||||||
klass = class_node(node)
|
klass = class_node(node)
|
||||||
resolve_relation_into_column(
|
resolve_relation_into_column(
|
||||||
name: name.to_s,
|
name: name.to_s,
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user