brew vendor-gems: commit updates.
This commit is contained in:
parent
0fb581b70e
commit
6f5a592217
@ -106,7 +106,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.46.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.17.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.16.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.17.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.18.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.18.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib")
|
||||
|
||||
@ -46,23 +46,6 @@ Lint/NumberConversion:
|
||||
- fortnights
|
||||
- in_milliseconds
|
||||
AllowedPatterns: []
|
||||
# Deprecated.
|
||||
IgnoredMethods:
|
||||
- ago
|
||||
- from_now
|
||||
- second
|
||||
- seconds
|
||||
- minute
|
||||
- minutes
|
||||
- hour
|
||||
- hours
|
||||
- day
|
||||
- days
|
||||
- week
|
||||
- weeks
|
||||
- fortnight
|
||||
- fortnights
|
||||
- in_milliseconds
|
||||
|
||||
Rails:
|
||||
Enabled: true
|
||||
@ -135,7 +118,9 @@ Rails/ActiveRecordOverride:
|
||||
Check for overriding Active Record methods instead of using
|
||||
callbacks.
|
||||
Enabled: true
|
||||
Severity: warning
|
||||
VersionAdded: '0.67'
|
||||
VersionChanged: '2.18'
|
||||
Include:
|
||||
- app/models/**/*.rb
|
||||
|
||||
@ -226,6 +211,9 @@ Rails/BelongsTo:
|
||||
Description: >-
|
||||
Use `optional: true` instead of `required: false` for
|
||||
`belongs_to` relations.
|
||||
Reference:
|
||||
- https://guides.rubyonrails.org/5_0_release_notes.html
|
||||
- https://github.com/rails/rails/pull/18937
|
||||
Enabled: true
|
||||
VersionAdded: '0.62'
|
||||
|
||||
@ -244,6 +232,9 @@ Rails/Blank:
|
||||
|
||||
Rails/BulkChangeTable:
|
||||
Description: 'Check whether alter queries are combinable.'
|
||||
Reference:
|
||||
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_table
|
||||
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html
|
||||
Enabled: true
|
||||
VersionAdded: '0.57'
|
||||
Database: null
|
||||
@ -330,9 +321,10 @@ Rails/DelegateAllowBlank:
|
||||
Rails/DeprecatedActiveModelErrorsMethods:
|
||||
Description: 'Avoid manipulating ActiveModel errors hash directly.'
|
||||
Enabled: pending
|
||||
Severity: warning
|
||||
Safe: false
|
||||
VersionAdded: '2.14'
|
||||
VersionChanged: '2.15'
|
||||
VersionChanged: '2.18'
|
||||
|
||||
Rails/DotSeparatedKeys:
|
||||
Description: 'Enforces the use of dot-separated keys instead of `:scope` options in `I18n` translation methods.'
|
||||
@ -343,12 +335,16 @@ Rails/DotSeparatedKeys:
|
||||
Rails/DuplicateAssociation:
|
||||
Description: "Don't repeat associations in a model."
|
||||
Enabled: pending
|
||||
Severity: warning
|
||||
VersionAdded: '2.14'
|
||||
VersionChanged: '2.18'
|
||||
|
||||
Rails/DuplicateScope:
|
||||
Description: 'Multiple scopes share this same where clause.'
|
||||
Enabled: pending
|
||||
Severity: warning
|
||||
VersionAdded: '2.14'
|
||||
VersionChanged: '2.18'
|
||||
|
||||
Rails/DurationArithmetic:
|
||||
Description: 'Do not use duration as arithmetic operand with `Time.current`.'
|
||||
@ -463,7 +459,7 @@ Rails/FindById:
|
||||
VersionAdded: '2.7'
|
||||
|
||||
Rails/FindEach:
|
||||
Description: 'Prefer all.find_each over all.find.'
|
||||
Description: 'Prefer all.find_each over all.each.'
|
||||
StyleGuide: 'https://rails.rubystyle.guide#find-each'
|
||||
Enabled: true
|
||||
VersionAdded: '0.30'
|
||||
@ -477,13 +473,6 @@ Rails/FindEach:
|
||||
- select
|
||||
- lock
|
||||
AllowedPatterns: []
|
||||
# Deprecated.
|
||||
IgnoredMethods:
|
||||
# Methods that don't work well with `find_each`.
|
||||
- order
|
||||
- limit
|
||||
- select
|
||||
- lock
|
||||
|
||||
Rails/FreezeTime:
|
||||
Description: 'Prefer `freeze_time` over `travel_to` with an argument of the current time.'
|
||||
@ -592,6 +581,9 @@ Rails/Inquiry:
|
||||
|
||||
Rails/InverseOf:
|
||||
Description: 'Checks for associations where the inverse cannot be determined automatically.'
|
||||
Reference:
|
||||
- https://guides.rubyonrails.org/association_basics.html#bi-directional-associations
|
||||
- https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses
|
||||
Enabled: true
|
||||
VersionAdded: '0.52'
|
||||
IgnoreScopes: false
|
||||
@ -695,7 +687,9 @@ Rails/Pluck:
|
||||
Description: 'Prefer `pluck` over `map { ... }`.'
|
||||
StyleGuide: 'https://rails.rubystyle.guide#pluck'
|
||||
Enabled: 'pending'
|
||||
Safe: false
|
||||
VersionAdded: '2.7'
|
||||
VersionChanged: '2.18'
|
||||
|
||||
Rails/PluckId:
|
||||
Description: 'Use `ids` instead of `pluck(:id)` or `pluck(primary_key)`.'
|
||||
@ -847,6 +841,17 @@ Rails/RequireDependency:
|
||||
Enabled: false
|
||||
VersionAdded: '2.10'
|
||||
|
||||
Rails/ResponseParsedBody:
|
||||
Description: Prefer `response.parsed_body` to `JSON.parse(response.body)`.
|
||||
Enabled: pending
|
||||
SafeAutoCorrect: false
|
||||
VersionAdded: '2.18'
|
||||
Include:
|
||||
- spec/controllers/**/*.rb
|
||||
- spec/requests/**/*.rb
|
||||
- test/controllers/**/*.rb
|
||||
- test/integration/**/*.rb
|
||||
|
||||
Rails/ReversibleMigration:
|
||||
Description: 'Checks whether the change method of the migration file is reversible.'
|
||||
StyleGuide: 'https://rails.rubystyle.guide#reversible-migration'
|
||||
@ -1038,10 +1043,14 @@ Rails/TopLevelHashWithIndifferentAccess:
|
||||
Description: 'Identifies top-level `HashWithIndifferentAccess`.'
|
||||
Reference: 'https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#top-level-hashwithindifferentaccess-is-soft-deprecated'
|
||||
Enabled: pending
|
||||
Severity: warning
|
||||
VersionAdded: '2.16'
|
||||
VersionChanged: '2.18'
|
||||
|
||||
Rails/TransactionExitStatement:
|
||||
Description: 'Avoid the usage of `return`, `break` and `throw` in transaction blocks.'
|
||||
Reference:
|
||||
- https://github.com/rails/rails/commit/15aa4200e083
|
||||
Enabled: pending
|
||||
VersionAdded: '2.14'
|
||||
|
||||
@ -1066,7 +1075,9 @@ Rails/UniqueValidationWithoutIndex:
|
||||
Rails/UnknownEnv:
|
||||
Description: 'Use correct environment name.'
|
||||
Enabled: true
|
||||
Severity: warning
|
||||
VersionAdded: '0.51'
|
||||
VersionChanged: '2.18'
|
||||
Environments:
|
||||
- development
|
||||
- test
|
||||
@ -1121,12 +1132,27 @@ Rails/WhereNot:
|
||||
Rails/WhereNotWithMultipleConditions:
|
||||
Description: 'Do not use `where.not(...)` with multiple conditions.'
|
||||
Enabled: 'pending'
|
||||
Severity: warning
|
||||
VersionAdded: '2.17'
|
||||
VersionChanged: '2.18'
|
||||
|
||||
# Accept `redirect_to(...) and return` and similar cases.
|
||||
Style/AndOr:
|
||||
EnforcedStyle: conditionals
|
||||
|
||||
Style/FormatStringToken:
|
||||
AllowedMethods:
|
||||
- redirect
|
||||
|
||||
Style/InverseMethods:
|
||||
# `InverseMethods` are methods that can be inverted by a not (`not` or `!`)
|
||||
# The relationship of inverse methods only needs to be defined in one direction.
|
||||
# Keys and values both need to be defined as symbols.
|
||||
InverseMethods:
|
||||
:present?: :blank?
|
||||
:include?: :exclude?
|
||||
:valid?: :invalid?
|
||||
|
||||
Style/SymbolProc:
|
||||
AllowedMethods:
|
||||
- define_method
|
||||
@ -67,9 +67,11 @@ module RuboCop
|
||||
private
|
||||
|
||||
def followed_by_render?(flash_node)
|
||||
flash_assigment_node = find_ancestor(flash_node, type: :send)
|
||||
context = flash_assigment_node
|
||||
flash_assignment_node = find_ancestor(flash_node, type: :send)
|
||||
context = flash_assignment_node
|
||||
if (node = context.each_ancestor(:if, :rescue).first)
|
||||
return false if use_redirect_to?(context)
|
||||
|
||||
context = node
|
||||
elsif context.right_siblings.empty?
|
||||
return true
|
||||
@ -95,6 +97,12 @@ module RuboCop
|
||||
def_node || block_node
|
||||
end
|
||||
|
||||
def use_redirect_to?(context)
|
||||
context.right_siblings.compact.any? do |sibling|
|
||||
sibling.send_type? && sibling.method?(:redirect_to)
|
||||
end
|
||||
end
|
||||
|
||||
def find_ancestor(node, type:)
|
||||
node.each_ancestor(type).first
|
||||
end
|
||||
@ -30,7 +30,7 @@ module RuboCop
|
||||
|
||||
def_node_matcher :action_controller_test_case?, <<~PATTERN
|
||||
(class
|
||||
(const {nil? cbase} _)
|
||||
(const _ _)
|
||||
(const (const {nil? cbase} :ActionController) :TestCase) _)
|
||||
PATTERN
|
||||
|
||||
@ -26,6 +26,8 @@ module RuboCop
|
||||
RESTRICT_ON_SEND = ALIASES.keys.freeze
|
||||
|
||||
def on_send(node)
|
||||
return if node.arguments.empty?
|
||||
|
||||
method_name = node.method_name
|
||||
alias_method = ALIASES[method_name]
|
||||
|
||||
@ -47,9 +47,6 @@ module RuboCop
|
||||
# class Post < ApplicationRecord
|
||||
# belongs_to :blog, optional: false
|
||||
# end
|
||||
#
|
||||
# @see https://guides.rubyonrails.org/5_0_release_notes.html
|
||||
# @see https://github.com/rails/rails/pull/18937
|
||||
class BelongsTo < Base
|
||||
extend AutoCorrector
|
||||
extend TargetRailsVersion
|
||||
@ -8,7 +8,7 @@ module RuboCop
|
||||
#
|
||||
# Interaction with `Style/UnlessElse`:
|
||||
# The configuration of `NotPresent` will not produce an offense in the
|
||||
# context of `unless else` if `Style/UnlessElse` is inabled. This is
|
||||
# context of `unless else` if `Style/UnlessElse` is enabled. This is
|
||||
# to prevent interference between the autocorrection of the two cops.
|
||||
#
|
||||
# @safety
|
||||
@ -62,9 +62,6 @@ module RuboCop
|
||||
# t.string :nickname
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# @see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_table
|
||||
# @see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html
|
||||
class BulkChangeTable < Base
|
||||
MSG_FOR_CHANGE_TABLE = <<~MSG.chomp
|
||||
You can combine alter queries using `bulk: true` options.
|
||||
@ -216,7 +213,7 @@ module RuboCop
|
||||
true
|
||||
when POSTGRESQL
|
||||
# Add bulk alter support for PostgreSQL in 5.2.0
|
||||
# @see https://github.com/rails/rails/pull/31331
|
||||
# See: https://github.com/rails/rails/pull/31331
|
||||
target_rails_version >= 5.2
|
||||
else
|
||||
false
|
||||
@ -160,7 +160,7 @@ module RuboCop
|
||||
end
|
||||
|
||||
def model_file?
|
||||
processed_source.buffer.name.include?('/models/')
|
||||
processed_source.file_path.include?('/models/')
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -26,6 +26,9 @@ module RuboCop
|
||||
#
|
||||
class FreezeTime < Base
|
||||
extend AutoCorrector
|
||||
extend TargetRailsVersion
|
||||
|
||||
minimum_target_rails_version 5.2
|
||||
|
||||
MSG = 'Use `freeze_time` instead of `travel_to`.'
|
||||
NOW_METHODS = %i[now new current].freeze
|
||||
@ -41,11 +41,11 @@ module RuboCop
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :association_without_options?, <<~PATTERN
|
||||
(send nil? {:has_many :has_one} _)
|
||||
(send _ {:has_many :has_one} _)
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :association_with_options?, <<~PATTERN
|
||||
(send nil? {:has_many :has_one} ... (hash $...))
|
||||
(send _ {:has_many :has_one} ... (hash $...))
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :dependent_option?, <<~PATTERN
|
||||
@ -35,8 +35,6 @@ module RuboCop
|
||||
# skip_before_action :login_required,
|
||||
# if: -> { trusted_origin? && action_name != "admin" }
|
||||
# end
|
||||
#
|
||||
# @see https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options
|
||||
class IgnoredSkipActionFilterOption < Base
|
||||
MSG = <<~MSG.chomp.freeze
|
||||
`%<ignore>s` option will be ignored when `%<prefer>s` and `%<ignore>s` are used together.
|
||||
@ -137,9 +137,6 @@ module RuboCop
|
||||
# class Blog < ApplicationRecord
|
||||
# has_many :posts, -> { order(published_at: :desc) }
|
||||
# end
|
||||
#
|
||||
# @see https://guides.rubyonrails.org/association_basics.html#bi-directional-associations
|
||||
# @see https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses
|
||||
class InverseOf < Base
|
||||
SPECIFY_MSG = 'Specify an `:inverse_of` option.'
|
||||
NIL_MSG = 'You specified `inverse_of: nil`, you probably meant to use `inverse_of: false`.'
|
||||
@ -144,19 +144,29 @@ module RuboCop
|
||||
end
|
||||
|
||||
def aliased_action_methods(node, defined_methods)
|
||||
alias_methods = node.each_child_node(:send).select { |send_node| send_node.method?(:alias_method) }
|
||||
|
||||
hash_of_alias_methods = alias_methods.each_with_object({}) do |alias_method, result|
|
||||
result[alias_method.last_argument.value] = alias_method.first_argument.value
|
||||
end
|
||||
|
||||
alias_methods = alias_methods(node)
|
||||
defined_methods.each_with_object([]) do |defined_method, aliased_method|
|
||||
if (new_method_name = hash_of_alias_methods[defined_method])
|
||||
if (new_method_name = alias_methods[defined_method])
|
||||
aliased_method << new_method_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def alias_methods(node)
|
||||
result = {}
|
||||
node.each_child_node(:send, :alias) do |child_node|
|
||||
case child_node.type
|
||||
when :send
|
||||
if child_node.method?(:alias_method)
|
||||
result[child_node.last_argument.value] = child_node.first_argument.value
|
||||
end
|
||||
when :alias
|
||||
result[child_node.old_identifier.value] = child_node.new_identifier.value
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
# @param node [RuboCop::AST::Node]
|
||||
# @return [Array<Symbol>]
|
||||
def array_values(node) # rubocop:disable Metrics/MethodLength
|
||||
@ -26,7 +26,7 @@ module RuboCop
|
||||
RESTRICT_ON_SEND = %i[!].freeze
|
||||
|
||||
def_node_matcher :negate_include_call?, <<~PATTERN
|
||||
(send (send $_ :include? $_) :!)
|
||||
(send (send $!nil? :include? $_) :!)
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
@ -21,7 +21,7 @@ module RuboCop
|
||||
RESTRICT_ON_SEND = %i[add_column add_reference].freeze
|
||||
|
||||
def_node_matcher :add_not_null_column?, <<~PATTERN
|
||||
(send nil? :add_column _ _ _ (hash $...))
|
||||
(send nil? :add_column _ _ $_ (hash $...))
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :add_not_null_reference?, <<~PATTERN
|
||||
@ -44,17 +44,20 @@ module RuboCop
|
||||
private
|
||||
|
||||
def check_add_column(node)
|
||||
pairs = add_not_null_column?(node)
|
||||
add_not_null_column?(node) do |type, pairs|
|
||||
return if type.value == :virtual || type.value == 'virtual'
|
||||
|
||||
check_pairs(pairs)
|
||||
end
|
||||
end
|
||||
|
||||
def check_add_reference(node)
|
||||
pairs = add_not_null_reference?(node)
|
||||
add_not_null_reference?(node) do |pairs|
|
||||
check_pairs(pairs)
|
||||
end
|
||||
end
|
||||
|
||||
def check_pairs(pairs)
|
||||
return unless pairs
|
||||
return if pairs.any? { |pair| default_option?(pair) }
|
||||
|
||||
null_false = pairs.find { |pair| null_false?(pair) }
|
||||
@ -9,6 +9,18 @@ module RuboCop
|
||||
# element in an enumerable. When called on an Active Record relation, it
|
||||
# results in a more efficient query that only selects the necessary key.
|
||||
#
|
||||
# @safety
|
||||
# This cop is unsafe because model can use column aliases.
|
||||
#
|
||||
# [source,ruby]
|
||||
# ----
|
||||
# # Original code
|
||||
# User.select('name AS nickname').map { |user| user[:nickname] } # => array of nicknames
|
||||
#
|
||||
# # After autocorrection
|
||||
# User.select('name AS nickname').pluck(:nickname) # => raises ActiveRecord::StatementInvalid
|
||||
# ----
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
# Post.published.map { |post| post[:title] }
|
||||
@ -112,10 +112,10 @@ module RuboCop
|
||||
end
|
||||
|
||||
def current(node)
|
||||
if node.source.include?("\n")
|
||||
if !node.ternary? && node.source.include?("\n")
|
||||
"#{node.loc.keyword.with(end_pos: node.condition.loc.selector.end_pos).source} ... end"
|
||||
else
|
||||
node.source
|
||||
node.source.gsub(/\n\s*/, ' ')
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,7 +8,7 @@ module RuboCop
|
||||
#
|
||||
# Interaction with `Style/UnlessElse`:
|
||||
# The configuration of `NotBlank` will not produce an offense in the
|
||||
# context of `unless else` if `Style/UnlessElse` is inabled. This is
|
||||
# context of `unless else` if `Style/UnlessElse` is enabled. This is
|
||||
# to prevent interference between the autocorrection of the two cops.
|
||||
#
|
||||
# @example NotNilAndNotEmpty: true (default)
|
||||
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