Merge pull request #12200 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rails-2.12.3
build(deps): bump rubocop-rails from 2.12.2 to 2.12.3 in /Library/Homebrew
This commit is contained in:
commit
ba4d3ca94f
@ -139,7 +139,7 @@ GEM
|
||||
rubocop-performance (1.11.5)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.12.2)
|
||||
rubocop-rails (2.12.3)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
|
||||
@ -387,6 +387,7 @@ class RuboCop::Cop::Rails::ContentTag < ::RuboCop::Cop::Base
|
||||
def autocorrect(corrector, node, preferred_method); end
|
||||
def corrected_ancestor?(node); end
|
||||
def correction_range(node); end
|
||||
def register_offense(node, message, preferred_method); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::ContentTag::MSG = T.let(T.unsafe(nil), String)
|
||||
@ -690,6 +691,8 @@ class RuboCop::Cop::Rails::FindEach < ::RuboCop::Cop::Base
|
||||
|
||||
private
|
||||
|
||||
def active_model_error?(node); end
|
||||
def active_model_error_where?(node); end
|
||||
def ignored?(node); end
|
||||
end
|
||||
|
||||
@ -89,7 +89,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.1.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.22.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.5/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.12.2/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.12.3/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.5.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"
|
||||
|
||||
@ -9,7 +9,7 @@ AllCops:
|
||||
- bin/*
|
||||
- db/schema.rb
|
||||
# What version of Rails is the inspected code using? If a value is specified
|
||||
# for TargetRailsVersion then it is used. Acceptable values are specificed
|
||||
# for TargetRailsVersion then it is used. Acceptable values are specified
|
||||
# as a float (i.e. 5.1); the patch version of Rails should not be included.
|
||||
# If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
|
||||
# gems.locked file to find the version of Rails that has been bound to the
|
||||
@ -189,6 +189,9 @@ Rails/ContentTag:
|
||||
Enabled: true
|
||||
VersionAdded: '2.6'
|
||||
VersionChanged: '2.12'
|
||||
# This `Exclude` config prevents false positives for `tag` calls to `has_one: tag`. No helpers are used in normal models.
|
||||
Exclude:
|
||||
- app/models/**/*.rb
|
||||
|
||||
Rails/CreateTableWithTimestamps:
|
||||
Description: >-
|
||||
@ -198,6 +201,10 @@ Rails/CreateTableWithTimestamps:
|
||||
VersionAdded: '0.52'
|
||||
Include:
|
||||
- db/migrate/*.rb
|
||||
Exclude:
|
||||
# Respect the `active_storage_variant_records` table of `*_create_active_storage_tables.active_storage.rb`
|
||||
# auto-generated by `bin/rails active_storage:install` even if `created_at` is not specified.
|
||||
- db/migrate/*_create_active_storage_tables.active_storage.rb
|
||||
|
||||
Rails/Date:
|
||||
Description: >-
|
||||
@ -816,7 +823,7 @@ Rails/UniqBeforePluck:
|
||||
AutoCorrect: false
|
||||
|
||||
Rails/UniqueValidationWithoutIndex:
|
||||
Description: 'Uniqueness validation should be with a unique index.'
|
||||
Description: 'Uniqueness validation should have a unique index on the database column.'
|
||||
Enabled: true
|
||||
VersionAdded: '2.5'
|
||||
Include:
|
||||
@ -33,6 +33,9 @@ module RuboCop
|
||||
end
|
||||
|
||||
def on_send(node)
|
||||
return unless node.receiver.nil?
|
||||
return if node.arguments.count >= 3
|
||||
|
||||
first_argument = node.first_argument
|
||||
return if !first_argument ||
|
||||
allowed_argument?(first_argument) ||
|
||||
@ -41,12 +44,7 @@ module RuboCop
|
||||
preferred_method = node.first_argument.value.to_s.underscore
|
||||
message = format(MSG, preferred_method: preferred_method, current_argument: first_argument.source)
|
||||
|
||||
add_offense(node, message: message) do |corrector|
|
||||
autocorrect(corrector, node, preferred_method)
|
||||
|
||||
@corrected_nodes ||= Set.new.compare_by_identity
|
||||
@corrected_nodes.add(node)
|
||||
end
|
||||
register_offense(node, message, preferred_method)
|
||||
end
|
||||
|
||||
private
|
||||
@ -63,6 +61,15 @@ module RuboCop
|
||||
allowed_name?(argument)
|
||||
end
|
||||
|
||||
def register_offense(node, message, preferred_method)
|
||||
add_offense(node, message: message) do |corrector|
|
||||
autocorrect(corrector, node, preferred_method)
|
||||
|
||||
@corrected_nodes ||= Set.new.compare_by_identity
|
||||
@corrected_nodes.add(node)
|
||||
end
|
||||
end
|
||||
|
||||
def autocorrect(corrector, node, preferred_method)
|
||||
range = correction_range(node)
|
||||
|
||||
@ -43,9 +43,20 @@ module RuboCop
|
||||
private
|
||||
|
||||
def ignored?(node)
|
||||
return true if active_model_error_where?(node.receiver)
|
||||
|
||||
method_chain = node.each_node(:send).map(&:method_name)
|
||||
|
||||
(cop_config['IgnoredMethods'].map(&:to_sym) & method_chain).any?
|
||||
end
|
||||
|
||||
def active_model_error_where?(node)
|
||||
node.method?(:where) && active_model_error?(node.receiver)
|
||||
end
|
||||
|
||||
def active_model_error?(node)
|
||||
node.send_type? && node.method?(:errors)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -90,7 +90,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def nested_relative_date(node, &callback)
|
||||
return if node.block_type?
|
||||
return if node.nil? || node.block_type?
|
||||
|
||||
node.each_child_node do |child|
|
||||
nested_relative_date(child, &callback)
|
||||
@ -317,16 +317,24 @@ module RuboCop
|
||||
return if receiver != node.receiver &&
|
||||
reversible_change_table_call?(node)
|
||||
|
||||
action = if method_name == :remove
|
||||
target_rails_version >= 6.1 ? 't.remove (without type)' : 't.remove'
|
||||
else
|
||||
"change_table(with #{method_name})"
|
||||
end
|
||||
|
||||
add_offense(
|
||||
node,
|
||||
message: format(MSG, action: "change_table(with #{method_name})")
|
||||
message: format(MSG, action: action)
|
||||
)
|
||||
end
|
||||
|
||||
def reversible_change_table_call?(node)
|
||||
case node.method_name
|
||||
when :change, :remove
|
||||
when :change
|
||||
false
|
||||
when :remove
|
||||
target_rails_version >= 6.1 && all_hash_key?(node.arguments.last, :type)
|
||||
when :change_default, :change_column_default, :change_table_comment,
|
||||
:change_column_comment
|
||||
all_hash_key?(node.arguments.last, :from, :to)
|
||||
@ -27,7 +27,7 @@ module RuboCop
|
||||
class UniqueValidationWithoutIndex < Base
|
||||
include ActiveRecordHelper
|
||||
|
||||
MSG = 'Uniqueness validation should be with a unique index.'
|
||||
MSG = 'Uniqueness validation should have a unique index on the database column.'
|
||||
RESTRICT_ON_SEND = %i[validates].freeze
|
||||
|
||||
def on_send(node)
|
||||
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