brew vendor-gems: commit updates.
This commit is contained in:
parent
4dd36fe5c4
commit
9f8d75eba7
@ -78,7 +78,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.3.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.9.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.0.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.5.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib"
|
||||
|
||||
@ -30,7 +30,7 @@ module RuboCop
|
||||
def on_send(node)
|
||||
return unless node.receiver&.send_type?
|
||||
return unless SCOPE_METHODS.include?(node.receiver.method_name)
|
||||
return if method_chain(node).any? { |m| ignored?(m) }
|
||||
return if ignored?(node)
|
||||
|
||||
range = node.loc.selector
|
||||
add_offense(range) do |corrector|
|
||||
@ -40,12 +40,9 @@ module RuboCop
|
||||
|
||||
private
|
||||
|
||||
def method_chain(node)
|
||||
node.each_node(:send).map(&:method_name)
|
||||
end
|
||||
|
||||
def ignored?(relation_method)
|
||||
cop_config['IgnoredMethods'].include?(relation_method)
|
||||
def ignored?(node)
|
||||
method_chain = node.each_node(:send).map(&:method_name)
|
||||
(cop_config['IgnoredMethods'].map(&:to_sym) & method_chain).any?
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -13,6 +13,9 @@ module RuboCop
|
||||
# variable, consider moving the behaviour elsewhere, for
|
||||
# example to a model, decorator or presenter.
|
||||
#
|
||||
# Provided that a class inherits `ActionView::Helpers::FormBuilder`,
|
||||
# an offense will not be registered.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# def welcome_message
|
||||
@ -23,18 +26,41 @@ module RuboCop
|
||||
# def welcome_message(user)
|
||||
# "Hello #{user.name}"
|
||||
# end
|
||||
#
|
||||
# # good
|
||||
# class MyFormBuilder < ActionView::Helpers::FormBuilder
|
||||
# @template.do_something
|
||||
# end
|
||||
class HelperInstanceVariable < Base
|
||||
MSG = 'Do not use instance variables in helpers.'
|
||||
|
||||
def_node_matcher :form_builder_class?, <<~PATTERN
|
||||
(const
|
||||
(const
|
||||
(const nil? :ActionView) :Helpers) :FormBuilder)
|
||||
PATTERN
|
||||
|
||||
def on_ivar(node)
|
||||
return if inherit_form_builder?(node)
|
||||
|
||||
add_offense(node)
|
||||
end
|
||||
|
||||
def on_ivasgn(node)
|
||||
return if node.parent.or_asgn_type?
|
||||
return if node.parent.or_asgn_type? || inherit_form_builder?(node)
|
||||
|
||||
add_offense(node.loc.name)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def inherit_form_builder?(node)
|
||||
node.each_ancestor(:class) do |class_node|
|
||||
return true if form_builder_class?(class_node.parent_class)
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -13,11 +13,13 @@ module RuboCop
|
||||
# User.where('name IS NULL')
|
||||
# User.where('name IN (?)', ['john', 'jane'])
|
||||
# User.where('name IN (:names)', names: ['john', 'jane'])
|
||||
# User.where('users.name = :name', name: 'Gabe')
|
||||
#
|
||||
# # good
|
||||
# User.where(name: 'Gabe')
|
||||
# User.where(name: nil)
|
||||
# User.where(name: ['john', 'jane'])
|
||||
# User.where(users: { name: 'Gabe' })
|
||||
class WhereEquals < Base
|
||||
include RangeHelp
|
||||
extend AutoCorrector
|
||||
@ -68,7 +70,7 @@ module RuboCop
|
||||
when EQ_ANONYMOUS_RE, IN_ANONYMOUS_RE
|
||||
value_node.source
|
||||
when EQ_NAMED_RE, IN_NAMED_RE
|
||||
return unless value_node.hash_type?
|
||||
return unless value_node&.hash_type?
|
||||
|
||||
pair = value_node.pairs.find { |p| p.key.value.to_sym == Regexp.last_match(2).to_sym }
|
||||
pair.value.source
|
||||
@ -83,7 +85,9 @@ module RuboCop
|
||||
|
||||
def build_good_method(column, value)
|
||||
if column.include?('.')
|
||||
"where('#{column}' => #{value})"
|
||||
table, column = column.split('.')
|
||||
|
||||
"where(#{table}: { #{column}: #{value} })"
|
||||
else
|
||||
"where(#{column}: #{value})"
|
||||
end
|
||||
@ -4,7 +4,7 @@ module RuboCop
|
||||
module Rails
|
||||
# This module holds the RuboCop Rails version information.
|
||||
module Version
|
||||
STRING = '2.9.0'
|
||||
STRING = '2.9.1'
|
||||
|
||||
def self.document_version
|
||||
STRING.match('\d+\.\d+').to_s
|
||||
Loading…
x
Reference in New Issue
Block a user