brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2022-11-05 17:45:47 +00:00
parent ce7ec97b36
commit 86532c4624
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
155 changed files with 695 additions and 172 deletions

View File

@ -27,7 +27,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/i18n-1.12.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/minitest-5.16.3/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/tzinfo-2.0.5/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/zeitwerk-2.6.1/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/zeitwerk-2.6.4/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/activesupport-6.1.7/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/public_suffix-5.0.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/addressable-2.8.1/lib")
@ -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/unicode-display_width-2.3.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.35.1/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.15.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.16.1/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rails-2.17.2/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.15.0/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.6.11/lib")
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib")

View File

@ -10,6 +10,9 @@ AllCops:
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
- db/*schema.rb
- log/**/*
- public/**/*
- storage/**/*
# Enable checking Active Support extensions.
# See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
ActiveSupportExtensionsEnabled: true
@ -70,7 +73,7 @@ Rails/ActionControllerFlashBeforeRender:
StyleGuide: 'https://rails.rubystyle.guide/#flash-before-render'
Reference: 'https://api.rubyonrails.org/classes/ActionController/FlashBeforeRender.html'
Enabled: 'pending'
SafeAutocorrect: false
SafeAutoCorrect: false
VersionAdded: '2.16'
Rails/ActionControllerTestCase:
@ -78,7 +81,7 @@ Rails/ActionControllerTestCase:
StyleGuide: 'https://rails.rubystyle.guide/#integration-testing'
Reference: 'https://api.rubyonrails.org/classes/ActionController/TestCase.html'
Enabled: 'pending'
SafeAutocorrect: false
SafeAutoCorrect: false
VersionAdded: '2.14'
Include:
- '**/test/**/*.rb'
@ -95,6 +98,21 @@ Rails/ActionFilter:
- app/controllers/**/*.rb
- app/mailers/**/*.rb
Rails/ActionOrder:
Description: 'Enforce consistent ordering of controller actions.'
Enabled: pending
VersionAdded: '2.17'
ExpectedOrder:
- index
- show
- new
- edit
- create
- update
- destroy
Include:
- app/controllers/**/*.rb
Rails/ActiveRecordAliases:
Description: >-
Avoid Active Record aliases:
@ -348,10 +366,13 @@ Rails/DynamicFindBy:
# The `Whitelist` has been deprecated, Please use `AllowedMethods` instead.
Whitelist:
- find_by_sql
- find_by_token_for
AllowedMethods:
- find_by_sql
- find_by_token_for
AllowedReceivers:
- Gem::Specification
- page # Prevents a warning for `page.find_by_id`. See: https://github.com/rubocop/rubocop-rails/issues/778
Rails/EagerEvaluationLogMessage:
Description: 'Checks that blocks are used for interpolated strings passed to `Rails.logger.debug`.'
@ -535,6 +556,13 @@ Rails/I18nLocaleTexts:
Enabled: pending
VersionAdded: '2.14'
Rails/IgnoredColumnsAssignment:
Description: 'Looks for assignments of `ignored_columns` that override previous assignments.'
StyleGuide: 'https://rails.rubystyle.guide/#append-ignored-columns'
Enabled: pending
SafeAutoCorrect: false
VersionAdded: '2.17'
Rails/IgnoredSkipActionFilterOption:
Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
@ -845,7 +873,7 @@ Rails/RootJoinChain:
Rails/RootPathnameMethods:
Description: 'Use `Rails.root` IO methods instead of passing it to `File`.'
Enabled: pending
SafeAutocorrect: false
SafeAutoCorrect: false
VersionAdded: '2.16'
Rails/RootPublicPath:
@ -1090,6 +1118,17 @@ Rails/WhereNot:
Enabled: 'pending'
VersionAdded: '2.8'
Rails/WhereNotWithMultipleConditions:
Description: 'Do not use `where.not(...)` with multiple conditions.'
Enabled: 'pending'
VersionAdded: '2.17'
# Accept `redirect_to(...) and return` and similar cases.
Style/AndOr:
EnforcedStyle: conditionals
Style/SymbolProc:
AllowedMethods:
- define_method
- mail
- respond_to

View File

@ -14,6 +14,16 @@ RuboCop::Rails::Inject.defaults!
require_relative 'rubocop/cop/rails_cops'
RuboCop::Cop::Style::HashExcept.minimum_target_ruby_version(2.0)
RuboCop::Cop::Style::MethodCallWithArgsParentheses.singleton_class.prepend(
Module.new do
def autocorrect_incompatible_with
super.push(RuboCop::Cop::Rails::EagerEvaluationLogMessage)
end
end
)
RuboCop::Cop::Style::RedundantSelf.singleton_class.prepend(
Module.new do
def autocorrect_incompatible_with

View File

@ -68,9 +68,12 @@ module RuboCop
def followed_by_render?(flash_node)
flash_assigment_node = find_ancestor(flash_node, type: :send)
context = flash_assigment_node.parent
context = flash_assigment_node
context = context.parent if context.parent.if_type?
context = context.right_siblings
return true if context.empty?
context.each_child_node.any? do |node|
context.compact.any? do |node|
render?(node)
end
end

View File

@ -31,7 +31,7 @@ module RuboCop
def_node_matcher :action_controller_test_case?, <<~PATTERN
(class
(const nil? _)
(const (const {nil? cbase} :ActionController) :TestCase) nil?)
(const (const {nil? cbase} :ActionController) :TestCase) _)
PATTERN
def on_class(node)

View File

@ -0,0 +1,81 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Rails
# Enforces consistent ordering of the standard Rails RESTful controller actions.
#
# The cop is configurable and can enforce any ordering of the standard actions.
# All other methods are ignored.
#
# [source,yaml]
# ----
# Rails/ActionOrder:
# ExpectedOrder:
# - index
# - show
# - new
# - edit
# - create
# - update
# - destroy
# ----
#
# @example
# # bad
# def index; end
# def destroy; end
# def show; end
#
# # good
# def index; end
# def show; end
# def destroy; end
class ActionOrder < Base
extend AutoCorrector
include VisibilityHelp
include DefNode
MSG = 'Action `%<current>s` should appear before `%<previous>s`.'
def_node_search :action_declarations, '(def {%1} ...)'
def on_class(node)
action_declarations(node, actions).each_cons(2) do |previous, current|
next if node_visibility(current) != :public || non_public?(current)
next if find_index(current) >= find_index(previous)
register_offense(previous, current)
end
end
private
def expected_order
cop_config['ExpectedOrder'].map(&:to_sym)
end
def actions
@actions ||= Set.new(expected_order)
end
def find_index(node)
expected_order.find_index(node.method_name)
end
def register_offense(previous, current)
message = format(
MSG,
expected_order: expected_order.join(', '),
previous: previous.method_name,
current: current.method_name
)
add_offense(current, message: message) do |corrector|
corrector.replace(current, previous.source)
corrector.replace(previous, current.source)
end
end
end
end
end
end

View File

@ -56,7 +56,8 @@ module RuboCop
argument.send_type? ||
argument.const_type? ||
argument.splat_type? ||
allowed_name?(argument)
allowed_name?(argument) ||
!argument.respond_to?(:value)
end
def register_offense(node, message, preferred_method)

View File

@ -22,19 +22,23 @@ module RuboCop
# User.find_by(name: name, email: email)
# User.find_by!(email: email)
#
# @example AllowedMethods: find_by_sql
# @example AllowedMethods: ['find_by_sql', 'find_by_token_for'] (default)
# # bad
# User.find_by_query(users_query)
# User.find_by_token_for(:password_reset, token)
#
# # good
# User.find_by_sql(users_sql)
# User.find_by_token_for(:password_reset, token)
#
# @example AllowedReceivers: Gem::Specification
# @example AllowedReceivers: ['Gem::Specification', 'page'] (default)
# # bad
# Specification.find_by_name('backend').gem_dir
# page.find_by_id('a_dom_id').click
#
# # good
# Gem::Specification.find_by_name('backend').gem_dir
# page.find_by_id('a_dom_id').click
class DynamicFindBy < Base
include ActiveRecordHelper
extend AutoCorrector

View File

@ -37,6 +37,10 @@ module RuboCop
)
PATTERN
def self.autocorrect_incompatible_with
[Style::MethodCallWithArgsParentheses]
end
def on_send(node)
return if node.parent&.block_type?

View File

@ -17,7 +17,7 @@ module RuboCop
# # good
# User.order(:foo).each
#
# @example AllowedPattern: [/order/]
# @example AllowedPattern: ['order']
# # good
# User.order(:foo).each
class FindEach < Base

View File

@ -43,7 +43,7 @@ module RuboCop
PATTERN
def on_send(node)
child_node, method_name, time_argument = *node.first_argument.children
child_node, method_name, time_argument = *node.first_argument&.children
return if time_argument || !child_node
return unless current_time?(child_node, method_name) || current_time_with_convert?(child_node, method_name)

View File

@ -0,0 +1,50 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Rails
# Looks for assignments of `ignored_columns` that may override previous
# assignments.
#
# Overwriting previous assignments is usually a mistake, since it will
# un-ignore the first set of columns. Since duplicate column names is not
# a problem, it is better to simply append to the list.
#
# @example
#
# # bad
# class User < ActiveRecord::Base
# self.ignored_columns = [:one]
# end
#
# # bad
# class User < ActiveRecord::Base
# self.ignored_columns = [:one, :two]
# end
#
# # good
# class User < ActiveRecord::Base
# self.ignored_columns += [:one, :two]
# end
#
# # good
# class User < ActiveRecord::Base
# self.ignored_columns += [:one]
# self.ignored_columns += [:two]
# end
#
class IgnoredColumnsAssignment < Base
extend AutoCorrector
MSG = 'Use `+=` instead of `=`.'
RESTRICT_ON_SEND = %i[ignored_columns=].freeze
def on_send(node)
add_offense(node.loc.operator) do |corrector|
corrector.replace(node.loc.operator, '+=')
end
end
end
end
end
end

View File

@ -21,42 +21,62 @@ module RuboCop
extend AutoCorrector
extend TargetRailsVersion
MSG = 'Prefer `pluck(:%<value>s)` over `%<current>s`.'
MSG = 'Prefer `%<replacement>s` over `%<current>s`.'
minimum_target_rails_version 5.0
def_node_matcher :pluck_candidate?, <<~PATTERN
({block numblock} (send _ {:map :collect}) $_argument (send (lvar $_element) :[] (sym $_value)))
({block numblock} (send _ {:map :collect}) $_argument (send lvar :[] $_key))
PATTERN
def on_block(node)
pluck_candidate?(node) do |argument, element, value|
pluck_candidate?(node) do |argument, key|
next unless use_one_block_argument?(argument)
match = if node.block_type?
argument.children.first.source.to_sym == element
block_argument = argument.children.first.source
use_block_argument_in_key?(block_argument, key)
else # numblock
argument == 1 && element == :_1
argument == 1 && use_block_argument_in_key?('_1', key)
end
next unless match
message = message(value, node)
add_offense(offense_range(node), message: message) do |corrector|
corrector.replace(offense_range(node), "pluck(:#{value})")
end
register_offense(node, key)
end
end
alias on_numblock on_block
private
def use_one_block_argument?(argument)
return true if argument == 1 # Checks for numbered argument `_1`.
argument.respond_to?(:one?) && argument.one?
end
def use_block_argument_in_key?(block_argument, key)
return false if block_argument == key.source
key.each_descendant(:lvar).none? { |lvar| block_argument == lvar.source }
end
def offense_range(node)
node.send_node.loc.selector.join(node.loc.end)
end
def message(value, node)
def register_offense(node, key)
replacement = "pluck(#{key.source})"
message = message(replacement, node)
add_offense(offense_range(node), message: message) do |corrector|
corrector.replace(offense_range(node), replacement)
end
end
def message(replacement, node)
current = offense_range(node).source
format(MSG, value: value, current: current)
format(MSG, replacement: replacement, current: current)
end
end
end

View File

@ -93,7 +93,7 @@ module RuboCop
def register_offense(node, receiver, other)
add_offense(node, message: message(node, receiver, other)) do |corrector|
corrector.replace(node.source_range, replacement(receiver, other))
corrector.replace(node.source_range, replacement(receiver, other, node.left_sibling))
end
end
@ -106,10 +106,20 @@ module RuboCop
end
def message(node, receiver, other)
format(MSG, prefer: replacement(receiver, other), current: node.source)
prefer = replacement(receiver, other, node.left_sibling).gsub(/^\s*|\n/, '')
current = current(node).gsub(/^\s*|\n/, '')
format(MSG, prefer: prefer, current: current)
end
def replacement(receiver, other)
def current(node)
if node.source.include?("\n")
"#{node.loc.keyword.with(end_pos: node.condition.loc.selector.end_pos).source} ... end"
else
node.source
end
end
def replacement(receiver, other, left_sibling)
or_source = if other&.send_type?
build_source_for_or_method(other)
elsif other.nil? || other.nil_type?
@ -118,23 +128,24 @@ module RuboCop
" || #{other.source}"
end
"#{receiver.source}.presence" + or_source
replaced = "#{receiver.source}.presence#{or_source}"
left_sibling ? "(#{replaced})" : replaced
end
def build_source_for_or_method(other)
if other.parenthesized? || other.method?('[]') || !other.arguments?
if other.parenthesized? || other.method?('[]') || other.arithmetic_operation? || !other.arguments?
" || #{other.source}"
else
method = range_between(
other.source_range.begin_pos,
other.first_argument.source_range.begin_pos - 1
).source
method = method_range(other).source
arguments = other.arguments.map(&:source).join(', ')
" || #{method}(#{arguments})"
end
end
def method_range(node)
range_between(node.source_range.begin_pos, node.first_argument.source_range.begin_pos - 1)
end
end
end
end

View File

@ -143,7 +143,7 @@ module RuboCop
def_node_matcher :belongs_to_without_fk?, <<~PATTERN
{
(send nil? :belongs_to (sym %1)) # belongs_to :user
(send nil? :belongs_to (sym %1) !hash) # belongs_to :user, -> { not_deleted }
(send nil? :belongs_to (sym %1) !hash ...) # belongs_to :user, -> { not_deleted }
(send nil? :belongs_to (sym %1) !(hash <(pair (sym :foreign_key) _) ...>))
}
PATTERN

View File

@ -98,6 +98,8 @@ module RuboCop
proc = if node.numblock_type?
->(n) { n.receiver.lvar_type? && n.receiver.source == '_1' }
else
return false if node.arguments.empty?
arg = node.arguments.first
->(n) { same_value?(arg, n.receiver) }
end

Some files were not shown because too many files have changed in this diff Show More