brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2021-09-09 18:06:25 +00:00
parent ab5f32a901
commit c4ac617a86
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
109 changed files with 223 additions and 102 deletions

View File

@ -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.20.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.11.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.12.0/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"

View File

@ -1,84 +0,0 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Rails
# This cop checks that `tag` is used instead of `content_tag`
# because `content_tag` is legacy syntax.
#
# NOTE: Allow `content_tag` when the first argument is a variable because
# `content_tag(name)` is simpler rather than `tag.public_send(name)`.
#
# @example
# # bad
# content_tag(:p, 'Hello world!')
# content_tag(:br)
#
# # good
# tag.p('Hello world!')
# tag.br
# content_tag(name, 'Hello world!')
class ContentTag < Base
include RangeHelp
extend AutoCorrector
extend TargetRailsVersion
minimum_target_rails_version 5.1
MSG = 'Use `tag` instead of `content_tag`.'
RESTRICT_ON_SEND = %i[content_tag].freeze
def on_new_investigation
@corrected_nodes = nil
end
def on_send(node)
first_argument = node.first_argument
return if !first_argument ||
allowed_argument?(first_argument) ||
corrected_ancestor?(node)
add_offense(node) do |corrector|
autocorrect(corrector, node)
@corrected_nodes ||= Set.new.compare_by_identity
@corrected_nodes.add(node)
end
end
private
def corrected_ancestor?(node)
node.each_ancestor(:send).any? { |ancestor| @corrected_nodes&.include?(ancestor) }
end
def allowed_argument?(argument)
argument.variable? || argument.send_type? || argument.const_type? || argument.splat_type?
end
def autocorrect(corrector, node)
if method_name?(node.first_argument)
range = correction_range(node)
rest_args = node.arguments.drop(1)
replacement = "tag.#{node.first_argument.value.to_s.underscore}(#{rest_args.map(&:source).join(', ')})"
corrector.replace(range, replacement)
else
corrector.replace(node.loc.selector, 'tag')
end
end
def method_name?(node)
return false unless node.str_type? || node.sym_type?
/^[a-zA-Z_][a-zA-Z_\-0-9]*$/.match?(node.value)
end
def correction_range(node)
range_between(node.loc.selector.begin_pos, node.loc.expression.end_pos)
end
end
end
end
end

View File

@ -181,12 +181,14 @@ Rails/BulkChangeTable:
- db/migrate/*.rb
Rails/ContentTag:
Description: 'Use `tag` instead of `content_tag`.'
Description: 'Use `tag.something` instead of `tag(:something)`.'
Reference:
- 'https://github.com/rubocop/rubocop-rails/issues/260'
- 'https://github.com/rails/rails/issues/25195'
- 'https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag'
Enabled: true
VersionAdded: '2.6'
VersionChanged: '2.12'
Rails/CreateTableWithTimestamps:
Description: >-
@ -499,6 +501,7 @@ Rails/OrderById:
Rails/Output:
Description: 'Checks for calls to puts, print, etc.'
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.15'
VersionChanged: '0.19'
Include:
@ -607,6 +610,14 @@ Rails/RedundantReceiverInWithOptions:
Enabled: true
VersionAdded: '0.52'
Rails/RedundantTravelBack:
Description: This cop checks for redundant `travel_back` calls.
Enabled: pending
VersionAdded: '2.12'
Include:
- spec/**/*.rb
- test/**/*.rb
Rails/ReflectionClassName:
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
Enabled: true
@ -713,6 +724,7 @@ Rails/ScopeArgs:
Description: 'Checks the arguments of ActiveRecord scopes.'
Enabled: true
VersionAdded: '0.19'
VersionChanged: '2.12'
Include:
- app/models/**/*.rb

View File

@ -0,0 +1,87 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Rails
# This cop checks legacy syntax usage of `tag`
#
# NOTE: Allow `tag` when the first argument is a variable because
# `tag(name)` is simpler rather than `tag.public_send(name)`.
# And this cop will be renamed to something like `LegacyTag` in the future. (e.g. RuboCop Rails 2.0)
#
# @example
# # bad
# tag(:p)
# tag(:br, class: 'classname')
#
# # good
# tag.p
# tag.br(class: 'classname')
# tag(name, class: 'classname')
class ContentTag < Base
include RangeHelp
extend AutoCorrector
extend TargetRailsVersion
minimum_target_rails_version 5.1
MSG = 'Use `tag.%<preferred_method>s` instead of `tag(%<current_argument>s)`.'
RESTRICT_ON_SEND = %i[tag].freeze
def on_new_investigation
@corrected_nodes = nil
end
def on_send(node)
first_argument = node.first_argument
return if !first_argument ||
allowed_argument?(first_argument) ||
corrected_ancestor?(node)
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
end
private
def corrected_ancestor?(node)
node.each_ancestor(:send).any? { |ancestor| @corrected_nodes&.include?(ancestor) }
end
def allowed_argument?(argument)
argument.variable? ||
argument.send_type? ||
argument.const_type? ||
argument.splat_type? ||
allowed_name?(argument)
end
def autocorrect(corrector, node, preferred_method)
range = correction_range(node)
rest_args = node.arguments.drop(1)
replacement = "tag.#{preferred_method}(#{rest_args.map(&:source).join(', ')})"
corrector.replace(range, replacement)
end
def allowed_name?(argument)
return false unless argument.str_type? || argument.sym_type?
!/^[a-zA-Z\-][a-zA-Z\-0-9]*$/.match?(argument.value)
end
def correction_range(node)
range_between(node.loc.selector.begin_pos, node.loc.expression.end_pos)
end
end
end
end
end

View File

@ -100,7 +100,7 @@ module RuboCop
def method_name_matches?(method_name, body)
method_name == body.method_name ||
include_prefix_case? && method_name == prefixed_method_name(body)
(include_prefix_case? && method_name == prefixed_method_name(body))
end
def include_prefix_case?

View File

@ -40,7 +40,7 @@ module RuboCop
IGNORED_ARGUMENT_TYPES = %i[hash splat].freeze
def on_send(node)
return if node.receiver.nil? && !inherit_active_record_base?(node) || allowed_invocation?(node)
return if (node.receiver.nil? && !inherit_active_record_base?(node)) || allowed_invocation?(node)
method_name = node.method_name
static_name = static_method_name(method_name)

View File

@ -114,6 +114,8 @@ module RuboCop
end
def valid_options?(options)
options = options.first.children.first.pairs if options.first.kwsplat_type?
return true unless options
return true if options.any? do |o|
dependent_option?(o) || present_option?(o)

View File

@ -27,6 +27,7 @@ module RuboCop
KEYWORD_ARGS = %i[
method params session body flash xhr as headers env to
].freeze
ROUTING_METHODS = %i[draw routes].freeze
RESTRICT_ON_SEND = %i[get post put patch delete head].freeze
minimum_target_rails_version 5.0
@ -40,6 +41,8 @@ module RuboCop
PATTERN
def on_send(node)
return if in_routing_block?(node)
http_request?(node) do |data|
return unless needs_conversion?(data)
@ -63,13 +66,17 @@ module RuboCop
private
def in_routing_block?(node)
!!node.each_ancestor(:block).detect { |block| ROUTING_METHODS.include?(block.send_node.method_name) }
end
def needs_conversion?(data)
return true unless data.hash_type?
return false if kwsplat_hash?(data)
data.each_pair.none? do |pair|
special_keyword_arg?(pair.key) ||
format_arg?(pair.key) && data.pairs.one?
(format_arg?(pair.key) && data.pairs.one?)
end
end

View File

@ -124,9 +124,10 @@ module RuboCop
block = parent.each_child_node(:begin).first
return unless block
defined_methods = block.each_child_node(:def).map(&:method_name)
defined_action_methods = defined_action_methods(block)
methods = array_values(methods_node).reject do |method|
defined_methods.include?(method)
defined_action_methods.include?(method)
end
message = message(methods, parent)
@ -135,6 +136,26 @@ module RuboCop
private
def defined_action_methods(block)
defined_methods = block.each_child_node(:def).map(&:method_name)
defined_methods + aliased_action_methods(block, defined_methods)
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
defined_methods.each_with_object([]) do |defined_method, aliased_method|
if (new_method_name = hash_of_alias_methods[defined_method])
aliased_method << new_method_name
end
end
end
# @param node [RuboCop::AST::Node]
# @return [Array<Symbol>]
def array_values(node) # rubocop:disable Metrics/MethodLength

View File

@ -75,8 +75,8 @@ module RuboCop
corrector.replace(str_range, "#{existing_rel} noopener")
end
def add_rel(send_node, offence_node, corrector)
opening_quote = offence_node.children.last.source[0]
def add_rel(send_node, offense_node, corrector)
opening_quote = offense_node.children.last.source[0]
closing_quote = opening_quote == ':' ? '' : opening_quote
new_rel_exp = ", rel: #{opening_quote}noopener#{closing_quote}"
range = if (last_argument = send_node.last_argument).hash_type?

View File

@ -14,6 +14,9 @@ module RuboCop
# # good
# Rails.logger.debug 'A debug message'
class Output < Base
include RangeHelp
extend AutoCorrector
MSG = 'Do not write to stdout. ' \
"Use Rails's logger if you want to log."
RESTRICT_ON_SEND = %i[
@ -35,10 +38,13 @@ module RuboCop
PATTERN
def on_send(node)
return unless (output?(node) || io_output?(node)) &&
node.arguments?
return unless (output?(node) || io_output?(node)) && node.arguments?
add_offense(node.loc.selector)
range = offense_range(node)
add_offense(range) do |corrector|
corrector.replace(range, 'Rails.logger.debug')
end
end
private
@ -46,6 +52,14 @@ module RuboCop
def match_gvar?(sym)
%i[$stdout $stderr].include?(sym)
end
def offense_range(node)
if node.receiver
range_between(node.loc.expression.begin_pos, node.loc.selector.end_pos)
else
node.loc.selector
end
end
end
end
end

View File

@ -61,8 +61,8 @@ module RuboCop
def offense?(node)
number, = *node.receiver
singular_receiver?(number) && plural_method?(node.method_name) ||
plural_receiver?(number) && singular_method?(node.method_name)
(singular_receiver?(number) && plural_method?(node.method_name)) ||
(plural_receiver?(number) && singular_method?(node.method_name))
end
def plural_method?(method_name)

View File

@ -0,0 +1,57 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Rails
# This cop checks for redundant `travel_back` calls.
# Since Rails 5.2, `travel_back` is automatically called at the end of the test.
#
# @example
#
# # bad
# def teardown
# do_something
# travel_back
# end
#
# # good
# def teardown
# do_something
# end
#
# # bad
# after do
# do_something
# travel_back
# end
#
# # good
# after do
# do_something
# end
#
class RedundantTravelBack < Base
include RangeHelp
extend AutoCorrector
extend TargetRailsVersion
minimum_target_rails_version 5.2
MSG = 'Redundant `travel_back` detected.'
RESTRICT_ON_SEND = %i[travel_back].freeze
def on_send(node)
return unless node.each_ancestor(:def, :block).any? do |ancestor|
method_name = ancestor.def_type? ? :teardown : :after
ancestor.method?(method_name)
end
add_offense(node) do |corrector|
corrector.remove(range_by_whole_lines(node.source_range, include_final_newline: true))
end
end
end
end
end
end

View File

@ -343,8 +343,8 @@ module RuboCop
def within_reversible_or_up_only_block?(node)
node.each_ancestor(:block).any? do |ancestor|
ancestor.block_type? &&
ancestor.send_node.method?(:reversible) ||
(ancestor.block_type? &&
ancestor.send_node.method?(:reversible)) ||
ancestor.send_node.method?(:up_only)
end
end

View File

@ -14,6 +14,8 @@ module RuboCop
# # good
# scope :something, -> { where(something: true) }
class ScopeArgs < Base
extend AutoCorrector
MSG = 'Use `lambda`/`proc` instead of a plain method call.'
RESTRICT_ON_SEND = %i[scope].freeze
@ -21,7 +23,9 @@ module RuboCop
def on_send(node)
scope?(node) do |second_arg|
add_offense(second_arg)
add_offense(second_arg) do |corrector|
corrector.replace(second_arg, "-> { #{second_arg.source} }")
end
end
end
end

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