Merge pull request #11704 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rails-2.11.3
build(deps): bump rubocop-rails from 2.11.2 to 2.11.3 in /Library/Homebrew
This commit is contained in:
commit
e4337e7969
@ -126,7 +126,7 @@ GEM
|
||||
rubocop-performance (1.11.4)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.11.2)
|
||||
rubocop-rails (2.11.3)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
|
||||
@ -17,6 +17,7 @@ module RuboCop::Cop::ActiveRecordHelper
|
||||
def foreign_key_of(belongs_to); end
|
||||
def in_where?(node); end
|
||||
def inherit_active_record_base?(node); end
|
||||
def polymorphic?(belongs_to); end
|
||||
def resolve_relation_into_column(name:, class_node:, table:); end
|
||||
def schema; end
|
||||
def table_name(class_node); end
|
||||
@ -144,8 +145,6 @@ class RuboCop::Cop::Rails::ActiveRecordCallbacksOrder < ::RuboCop::Cop::Base
|
||||
def defined_callbacks(class_node); end
|
||||
def end_position_for(node); end
|
||||
def inline_comment?(comment); end
|
||||
def left_siblings_of(node); end
|
||||
def siblings_of(node); end
|
||||
def source_range_with_comment(node); end
|
||||
def start_line_position(node); end
|
||||
end
|
||||
@ -1212,10 +1211,8 @@ class RuboCop::Cop::Rails::RedundantAllowNil < ::RuboCop::Cop::Base
|
||||
private
|
||||
|
||||
def find_allow_nil_and_allow_blank(node); end
|
||||
def next_sibling(node); end
|
||||
def node_beg(node); end
|
||||
def node_end(node); end
|
||||
def previous_sibling(node); end
|
||||
def register_offense(allow_nil, message); end
|
||||
end
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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)
|
||||
@ -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)
|
||||
@ -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
|
||||
@ -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
Loading…
x
Reference in New Issue
Block a user