brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2022-06-14 18:05:29 +00:00
parent e240ced331
commit 2b44142efb
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
129 changed files with 509 additions and 165 deletions

View File

@ -86,7 +86,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/unicode-display_width-2.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.27.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.27.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.14.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.14.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.14.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.15.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.11.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.11.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.8/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.8/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-3.0.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-3.0.0/lib"

View File

@ -60,6 +60,7 @@ Rails/ActionFilter:
- filter - filter
Include: Include:
- app/controllers/**/*.rb - app/controllers/**/*.rb
- app/mailers/**/*.rb
Rails/ActiveRecordAliases: Rails/ActiveRecordAliases:
Description: >- Description: >-
@ -107,7 +108,7 @@ Rails/AddColumnIndex:
Rails/AfterCommitOverride: Rails/AfterCommitOverride:
Description: >- Description: >-
This cop enforces that there is only one call to `after_commit` Enforces that there is only one call to `after_commit`
(and its aliases - `after_create_commit`, `after_update_commit`, (and its aliases - `after_create_commit`, `after_update_commit`,
and `after_destroy_commit`) with the same callback name per model. and `after_destroy_commit`) with the same callback name per model.
Enabled: 'pending' Enabled: 'pending'
@ -271,6 +272,13 @@ Rails/DeprecatedActiveModelErrorsMethods:
Enabled: pending Enabled: pending
Safe: false Safe: false
VersionAdded: '2.14' VersionAdded: '2.14'
VersionChanged: '2.15'
Rails/DotSeparatedKeys:
Description: 'Enforces the use of dot-separated keys instead of `:scope` options in `I18n` translation methods.'
StyleGuide: 'https://rails.rubystyle.guide/#dot-separated-keys'
Enabled: pending
VersionAdded: '2.15'
Rails/DuplicateAssociation: Rails/DuplicateAssociation:
Description: "Don't repeat associations in a model." Description: "Don't repeat associations in a model."
@ -476,6 +484,7 @@ Rails/IgnoredSkipActionFilterOption:
VersionAdded: '0.63' VersionAdded: '0.63'
Include: Include:
- app/controllers/**/*.rb - app/controllers/**/*.rb
- app/mailers/**/*.rb
Rails/IndexBy: Rails/IndexBy:
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.' Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
@ -504,13 +513,14 @@ Rails/InverseOf:
- app/models/**/*.rb - app/models/**/*.rb
Rails/LexicallyScopedActionFilter: Rails/LexicallyScopedActionFilter:
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller." Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
StyleGuide: 'https://rails.rubystyle.guide#lexically-scoped-action-filter' StyleGuide: 'https://rails.rubystyle.guide#lexically-scoped-action-filter'
Enabled: true Enabled: true
Safe: false Safe: false
VersionAdded: '0.52' VersionAdded: '0.52'
Include: Include:
- app/controllers/**/*.rb - app/controllers/**/*.rb
- app/mailers/**/*.rb
Rails/LinkToBlank: Rails/LinkToBlank:
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.' Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
@ -690,7 +700,7 @@ Rails/RedundantReceiverInWithOptions:
VersionAdded: '0.52' VersionAdded: '0.52'
Rails/RedundantTravelBack: Rails/RedundantTravelBack:
Description: This cop checks for redundant `travel_back` calls. Description: Checks for redundant `travel_back` calls.
Enabled: pending Enabled: pending
VersionAdded: '2.12' VersionAdded: '2.12'
Include: Include:
@ -774,6 +784,11 @@ Rails/RootJoinChain:
Enabled: pending Enabled: pending
VersionAdded: '2.13' VersionAdded: '2.13'
Rails/RootPublicPath:
Description: "Favor `Rails.public_path` over `Rails.root` with `'public'`."
Enabled: pending
VersionAdded: '2.15'
Rails/SafeNavigation: Rails/SafeNavigation:
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`." Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`."
Enabled: true Enabled: true
@ -808,7 +823,7 @@ Rails/SaveBang:
Rails/SchemaComment: Rails/SchemaComment:
Description: >- Description: >-
This cop enforces the use of the `comment` option when adding a new table or column Enforces the use of the `comment` option when adding a new table or column
to the database during a migration. to the database during a migration.
Enabled: false Enabled: false
VersionAdded: '2.13' VersionAdded: '2.13'
@ -867,9 +882,15 @@ Rails/SquishedSQLHeredocs:
VersionAdded: '2.8' VersionAdded: '2.8'
VersionChanged: '2.9' VersionChanged: '2.9'
# Some SQL syntax (e.g. PostgreSQL comments and functions) requires newlines # Some SQL syntax (e.g. PostgreSQL comments and functions) requires newlines
# to be preserved in order to work, thus auto-correction is not safe. # to be preserved in order to work, thus autocorrection is not safe.
SafeAutoCorrect: false SafeAutoCorrect: false
Rails/StripHeredoc:
Description: 'Enforces the use of squiggly heredoc over `strip_heredoc`.'
StyleGuide: 'https://rails.rubystyle.guide/#prefer-squiggly-heredoc'
Enabled: pending
VersionAdded: '2.15'
Rails/TableNameAssignment: Rails/TableNameAssignment:
Description: >- Description: >-
Do not use `self.table_name =`. Use Inflections or `table_name_prefix` instead. Do not use `self.table_name =`. Use Inflections or `table_name_prefix` instead.
@ -905,6 +926,16 @@ Rails/TimeZoneAssignment:
- spec/**/*.rb - spec/**/*.rb
- test/**/*.rb - test/**/*.rb
Rails/ToFormattedS:
Description: 'Checks for consistent uses of `to_fs` or `to_formatted_s`.'
StyleGuide: 'https://rails.rubystyle.guide/#prefer-to-fs'
Enabled: pending
EnforcedStyle: to_fs
SupportedStyles:
- to_fs
- to_formatted_s
VersionAdded: '2.15'
Rails/TransactionExitStatement: Rails/TransactionExitStatement:
Description: 'Avoid the usage of `return`, `break` and `throw` in transaction blocks.' Description: 'Avoid the usage of `return`, `break` and `throw` in transaction blocks.'
Enabled: pending Enabled: pending

View File

@ -13,3 +13,11 @@ require_relative 'rubocop/rails/schema_loader/schema'
RuboCop::Rails::Inject.defaults! RuboCop::Rails::Inject.defaults!
require_relative 'rubocop/cop/rails_cops' require_relative 'rubocop/cop/rails_cops'
RuboCop::Cop::Style::RedundantSelf.singleton_class.prepend(
Module.new do
def autocorrect_incompatible_with
super.push(RuboCop::Cop::Rails::SafeNavigation)
end
end
)

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces the consistent use of action filter methods. # Enforces the consistent use of action filter methods.
# #
# The cop is configurable and can enforce the use of the older # The cop is configurable and can enforce the use of the older
# something_filter methods or the newer something_action methods. # something_filter methods or the newer something_action methods.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that Active Record callbacks are declared # Checks that Active Record callbacks are declared
# in the order in which they will be executed. # in the order in which they will be executed.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that ActiveSupport aliases to core ruby methods # Checks that ActiveSupport aliases to core ruby methods
# are not used. # are not used.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for migrations using `add_column` that have an `index` # Checks for migrations using `add_column` that have an `index`
# key. `add_column` does not accept `index`, but also does not raise an # key. `add_column` does not accept `index`, but also does not raise an
# error for extra keys, so it is possible to mistakenly add the key without # error for extra keys, so it is possible to mistakenly add the key without
# realizing it will not actually add an index. # realizing it will not actually add an index.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces that there is only one call to `after_commit` # Enforces that there is only one call to `after_commit`
# (and its aliases - `after_create_commit`, `after_update_commit`, # (and its aliases - `after_create_commit`, `after_update_commit`,
# and `after_destroy_commit`) with the same callback name per model. # and `after_destroy_commit`) with the same callback name per model.
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that controllers subclass `ApplicationController`. # Checks that controllers subclass `ApplicationController`.
# #
# @safety # @safety
# This cop's autocorrection is unsafe because it may let the logic from `ApplicationController` # This cop's autocorrection is unsafe because it may let the logic from `ApplicationController`

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that jobs subclass `ApplicationJob` with Rails 5.0. # Checks that jobs subclass `ApplicationJob` with Rails 5.0.
# #
# @safety # @safety
# This cop's autocorrection is unsafe because it may let the logic from `ApplicationJob` # This cop's autocorrection is unsafe because it may let the logic from `ApplicationJob`

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that mailers subclass `ApplicationMailer` with Rails 5.0. # Checks that mailers subclass `ApplicationMailer` with Rails 5.0.
# #
# @safety # @safety
# This cop's autocorrection is unsafe because it may let the logic from `ApplicationMailer` # This cop's autocorrection is unsafe because it may let the logic from `ApplicationMailer`

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that models subclass `ApplicationRecord` with Rails 5.0. # Checks that models subclass `ApplicationRecord` with Rails 5.0.
# #
# @safety # @safety
# This cop's autocorrection is unsafe because it may let the logic from `ApplicationRecord` # This cop's autocorrection is unsafe because it may let the logic from `ApplicationRecord`

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop prevents usage of `"*"` on an Arel::Table column reference. # Prevents usage of `"*"` on an Arel::Table column reference.
# #
# Using `arel_table["*"]` causes the outputted string to be a literal # Using `arel_table["*"]` causes the outputted string to be a literal
# quoted asterisk (e.g. <tt>`my_model`.`*`</tt>). This causes the # quoted asterisk (e.g. <tt>`my_model`.`*`</tt>). This causes the

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for `attribute` class methods that specify a `:default` option # Looks for `attribute` class methods that specify a `:default` option
# which value is an array, string literal or method call without a block. # which value is an array, string literal or method call without a block.
# It will accept all other values, such as string, symbol, integer and float literals # It will accept all other values, such as string, symbol, integer and float literals
# as well as constants. # as well as constants.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for belongs_to associations where we control whether the # Looks for belongs_to associations where we control whether the
# association is required via the deprecated `required` option instead. # association is required via the deprecated `required` option instead.
# #
# Since Rails 5, belongs_to associations are required by default and this # Since Rails 5, belongs_to associations are required by default and this

View File

@ -3,17 +3,17 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for code that can be written with simpler conditionals # Checks for code that can be written with simpler conditionals
# using `Object#blank?` defined by Active Support. # using `Object#blank?` defined by Active Support.
# #
# Interaction with `Style/UnlessElse`: # Interaction with `Style/UnlessElse`:
# The configuration of `NotPresent` will not produce an offense in the # 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 inabled. This is
# to prevent interference between the auto-correction of the two cops. # to prevent interference between the autocorrection of the two cops.
# #
# @safety # @safety
# This cop is unsafe auto-correction, because `' '.empty?` returns false, # This cop is unsafe autocorrection, because `' '.empty?` returns false,
# but `' '.blank?` returns true. Therefore, auto-correction is not compatible # but `' '.blank?` returns true. Therefore, autocorrection is not compatible
# if the receiver is a non-empty blank string, tab, or newline meta characters. # if the receiver is a non-empty blank string, tab, or newline meta characters.
# #
# @example NilOrEmpty: true (default) # @example NilOrEmpty: true (default)

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This Cop checks whether alter queries are combinable. # Checks whether alter queries are combinable.
# If combinable queries are detected, it suggests to you # If combinable queries are detected, it suggests to you
# to use `change_table` with `bulk: true` instead. # to use `change_table` with `bulk: true` instead.
# This option causes the migration to generate a single # This option causes the migration to generate a single

View File

@ -17,7 +17,7 @@ module RuboCop
# `ActionController::Parameters`. # `ActionController::Parameters`.
# `Array#compact_blank!`, `Hash#compact_blank!` are equivalent to `delete_if(&:blank?)`. # `Array#compact_blank!`, `Hash#compact_blank!` are equivalent to `delete_if(&:blank?)`.
# `ActionController::Parameters#compact_blank!` is equivalent to `reject!(&:blank?)`. # `ActionController::Parameters#compact_blank!` is equivalent to `reject!(&:blank?)`.
# If the cop makes a mistake, auto-corrected code may get unexpected behavior. # If the cop makes a mistake, autocorrected code may get unexpected behavior.
# #
# @example # @example
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks legacy syntax usage of `tag` # Checks legacy syntax usage of `tag`
# #
# NOTE: Allow `tag` when the first argument is a variable because # NOTE: Allow `tag` when the first argument is a variable because
# `tag(name)` is simpler rather than `tag.public_send(name)`. # `tag(name)` is simpler rather than `tag.public_send(name)`.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks the migration for which timestamps are not included # Checks the migration for which timestamps are not included
# when creating a new table. # when creating a new table.
# In many cases, timestamps are useful information and should be added. # In many cases, timestamps are useful information and should be added.
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for the correct use of Date methods, # Checks for the correct use of Date methods,
# such as Date.today, Date.current etc. # such as Date.today, Date.current etc.
# #
# Using `Date.today` is dangerous, because it doesn't know anything about # Using `Date.today` is dangerous, because it doesn't know anything about
@ -22,16 +22,6 @@ module RuboCop
# And you can set a warning for `to_time` with `AllowToTime: false`. # And you can set a warning for `to_time` with `AllowToTime: false`.
# `AllowToTime` is `true` by default to prevent false positive on `DateTime` object. # `AllowToTime` is `true` by default to prevent false positive on `DateTime` object.
# #
# @example EnforcedStyle: strict
# # bad
# Date.current
# Date.yesterday
# Date.today
#
# # good
# Time.zone.today
# Time.zone.today - 1.day
#
# @example EnforcedStyle: flexible (default) # @example EnforcedStyle: flexible (default)
# # bad # # bad
# Date.today # Date.today
@ -43,6 +33,16 @@ module RuboCop
# Date.yesterday # Date.yesterday
# date.in_time_zone # date.in_time_zone
# #
# @example EnforcedStyle: strict
# # bad
# Date.current
# Date.yesterday
# Date.today
#
# # good
# Time.zone.today
# Time.zone.today - 1.day
#
# @example AllowToTime: true (default) # @example AllowToTime: true (default)
# # good # # good
# date.to_time # date.to_time

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for uses of `default_scope`. # Looks for uses of `default_scope`.
# #
# @example # @example
# # bad # # bad

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for delegations that could have been created # Looks for delegations that could have been created
# automatically with the `delegate` method. # automatically with the `delegate` method.
# #
# Safe navigation `&.` is ignored because Rails' `allow_nil` # Safe navigation `&.` is ignored because Rails' `allow_nil`

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for delegations that pass :allow_blank as an option # Looks for delegations that pass :allow_blank as an option
# instead of :allow_nil. :allow_blank is not a valid option to pass # instead of :allow_nil. :allow_blank is not a valid option to pass
# to ActiveSupport#delegate. # to ActiveSupport#delegate.
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks direct manipulation of ActiveModel#errors as hash. # Checks direct manipulation of ActiveModel#errors as hash.
# These operations are deprecated in Rails 6.1 and will not work in Rails 7. # These operations are deprecated in Rails 6.1 and will not work in Rails 7.
# #
# @safety # @safety
@ -26,8 +26,18 @@ module RuboCop
# # good # # good
# user.errors.delete(:name) # user.errors.delete(:name)
# #
# # bad
# user.errors.keys.include?(:attr)
#
# # good
# user.errors.attribute_names.include?(:attr)
#
class DeprecatedActiveModelErrorsMethods < Base class DeprecatedActiveModelErrorsMethods < Base
include RangeHelp
extend AutoCorrector
MSG = 'Avoid manipulating ActiveModel errors as hash directly.' MSG = 'Avoid manipulating ActiveModel errors as hash directly.'
AUTOCORECTABLE_METHODS = %i[<< clear keys].freeze
MANIPULATIVE_METHODS = Set[ MANIPULATIVE_METHODS = Set[
*%i[ *%i[
@ -45,6 +55,7 @@ module RuboCop
{ {
#root_manipulation? #root_manipulation?
#root_assignment? #root_assignment?
#errors_keys?
#messages_details_manipulation? #messages_details_manipulation?
#messages_details_assignment? #messages_details_assignment?
} }
@ -66,6 +77,12 @@ module RuboCop
...) ...)
PATTERN PATTERN
def_node_matcher :errors_keys?, <<~PATTERN
(send
(send #receiver_matcher :errors)
:keys)
PATTERN
def_node_matcher :messages_details_manipulation?, <<~PATTERN def_node_matcher :messages_details_manipulation?, <<~PATTERN
(send (send
(send (send
@ -89,12 +106,49 @@ module RuboCop
def on_send(node) def on_send(node)
any_manipulation?(node) do any_manipulation?(node) do
add_offense(node) add_offense(node) do |corrector|
next unless AUTOCORECTABLE_METHODS.include?(node.method_name)
autocorrect(corrector, node)
end
end end
end end
private private
def autocorrect(corrector, node)
receiver = node.receiver
if receiver.receiver.method?(:messages)
corrector.remove(receiver.receiver.loc.dot)
corrector.remove(receiver.receiver.loc.selector)
end
range = offense_range(node, receiver)
replacement = replacement(node, receiver)
corrector.replace(range, replacement)
end
def offense_range(node, receiver)
range_between(receiver.receiver.source_range.end_pos, node.source_range.end_pos)
end
def replacement(node, receiver)
return '.errors.attribute_names' if node.method?(:keys)
key = receiver.first_argument.source
case node.method_name
when :<<
value = node.first_argument.source
".add(#{key}, #{value})"
when :clear
".delete(#{key})"
end
end
def receiver_matcher(node) def receiver_matcher(node)
model_file? ? receiver_matcher_inside_model(node) : receiver_matcher_outside_model(node) model_file? ? receiver_matcher_inside_model(node) : receiver_matcher_outside_model(node)
end end

View File

@ -0,0 +1,71 @@
# frozen_string_literal: true
module RuboCop
module Cop
module Rails
# Enforces the use of dot-separated locale keys instead of specifying the `:scope` option
# with an array or a single symbol in `I18n` translation methods.
# Dot-separated notation is easier to read and trace the hierarchy.
#
# @example
# # bad
# I18n.t :record_invalid, scope: [:activerecord, :errors, :messages]
# I18n.t :title, scope: :invitation
#
# # good
# I18n.t 'activerecord.errors.messages.record_invalid'
# I18n.t :record_invalid, scope: 'activerecord.errors.messages'
#
class DotSeparatedKeys < Base
include RangeHelp
extend AutoCorrector
MSG = 'Use the dot-separated keys instead of specifying the `:scope` option.'
TRANSLATE_METHODS = %i[translate t].freeze
def_node_matcher :translate_with_scope?, <<~PATTERN
(send {nil? (const nil? :I18n)} {:translate :t} ${sym_type? str_type?}
(hash <$(pair (sym :scope) ${array_type? sym_type?}) ...>)
)
PATTERN
def on_send(node)
return unless TRANSLATE_METHODS.include?(node.method_name)
translate_with_scope?(node) do |key_node, scope_node|
return unless should_convert_scope?(scope_node)
add_offense(scope_node) do |corrector|
# Eat the comma on the left.
range = range_with_surrounding_space(range: scope_node.source_range, side: :left)
range = range_with_surrounding_comma(range, :left)
corrector.remove(range)
corrector.replace(key_node, new_key(key_node, scope_node))
end
end
end
private
def should_convert_scope?(scope_node)
scopes(scope_node).all?(&:basic_literal?)
end
def new_key(key_node, scope_node)
"'#{scopes(scope_node).map(&:value).join('.')}.#{key_node.value}'"
end
def scopes(scope_node)
value = scope_node.value
if value.array_type?
value.values
else
[value]
end
end
end
end
end
end

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for associations that have been defined multiple times in the same file. # Looks for associations that have been defined multiple times in the same file.
# #
# When an association is defined multiple times on a model, Active Record overrides the # When an association is defined multiple times on a model, Active Record overrides the
# previously defined association with the new one. Because of this, this cop's autocorrection # previously defined association with the new one. Because of this, this cop's autocorrection
@ -35,7 +35,7 @@ module RuboCop
offenses(class_node).each do |name, nodes| offenses(class_node).each do |name, nodes|
nodes.each do |node| nodes.each do |node|
add_offense(node, message: format(MSG, name: name)) do |corrector| add_offense(node, message: format(MSG, name: name)) do |corrector|
next if nodes.last == node next if same_line?(nodes.last, node)
corrector.remove(range_by_whole_lines(node.source_range, include_final_newline: true)) corrector.remove(range_by_whole_lines(node.source_range, include_final_newline: true))
end end

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for multiple scopes in a model that have the same `where` clause. This # Checks for multiple scopes in a model that have the same `where` clause. This
# often means you copy/pasted a scope, updated the name, and forgot to change the condition. # often means you copy/pasted a scope, updated the name, and forgot to change the condition.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks if a duration is added to or subtracted from `Time.current`. # Checks if a duration is added to or subtracted from `Time.current`.
# #
# @example # @example
# # bad # # bad

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks dynamic `find_by_*` methods. # Checks dynamic `find_by_*` methods.
# Use `find_by` instead of dynamic method. # Use `find_by` instead of dynamic method.
# See. https://rails.rubystyle.guide#find_by # See. https://rails.rubystyle.guide#find_by
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that blocks are used for interpolated strings passed to # Checks that blocks are used for interpolated strings passed to
# `Rails.logger.debug`. # `Rails.logger.debug`.
# #
# By default, Rails production environments use the `:info` log level. # By default, Rails production environments use the `:info` log level.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for enums written with array syntax. # Looks for enums written with array syntax.
# #
# When using array syntax, adding an element in a # When using array syntax, adding an element in a
# position other than the last causes all previous # position other than the last causes all previous

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for duplicate values in enum declarations. # Looks for duplicate values in enum declarations.
# #
# @example # @example
# # bad # # bad

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that Rails.env is compared using `.production?`-like # Checks that Rails.env is compared using `.production?`-like
# methods instead of equality against a string or symbol. # methods instead of equality against a string or symbol.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for direct access to environment variables through the # Looks for direct access to environment variables through the
# `ENV` variable within the application code. This can lead to runtime # `ENV` variable within the application code. This can lead to runtime
# errors due to misconfiguration that could have been discovered at boot # errors due to misconfiguration that could have been discovered at boot
# time if the environment variables were loaded as part of initialization # time if the environment variables were loaded as part of initialization

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces that `exit` calls are not used within a rails app. # Enforces that `exit` calls are not used within a rails app.
# Valid options are instead to raise an error, break, return, or some # Valid options are instead to raise an error, break, return, or some
# other form of stopping execution of current request. # other form of stopping execution of current request.
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for expanded date range. It only compatible `..` range is targeted. # Checks for expanded date range. It only compatible `..` range is targeted.
# Incompatible `...` range is ignored. # Incompatible `...` range is ignored.
# #
# @example # @example

View File

@ -3,19 +3,10 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop is used to identify usages of file path joining process # Identifies usages of file path joining process
# to use `Rails.root.join` clause. It is used to add uniformity when # to use `Rails.root.join` clause. It is used to add uniformity when
# joining paths. # joining paths.
# #
# @example EnforcedStyle: arguments
# # bad
# Rails.root.join('app/models/goober')
# File.join(Rails.root, 'app/models/goober')
# "#{Rails.root}/app/models/goober"
#
# # good
# Rails.root.join('app', 'models', 'goober')
#
# @example EnforcedStyle: slashes (default) # @example EnforcedStyle: slashes (default)
# # bad # # bad
# Rails.root.join('app', 'models', 'goober') # Rails.root.join('app', 'models', 'goober')
@ -25,6 +16,15 @@ module RuboCop
# # good # # good
# Rails.root.join('app/models/goober') # Rails.root.join('app/models/goober')
# #
# @example EnforcedStyle: arguments
# # bad
# Rails.root.join('app/models/goober')
# File.join(Rails.root, 'app/models/goober')
# "#{Rails.root}/app/models/goober"
#
# # good
# Rails.root.join('app', 'models', 'goober')
#
class FilePath < Base class FilePath < Base
include ConfigurableEnforcedStyle include ConfigurableEnforcedStyle
include RangeHelp include RangeHelp
@ -48,8 +48,11 @@ module RuboCop
def on_dstr(node) def on_dstr(node)
return unless rails_root_nodes?(node) return unless rails_root_nodes?(node)
return unless node.children.last.str_type? return unless node.children.last.str_type?
return unless node.children.last.source.start_with?('.') ||
node.children.last.source.include?(File::SEPARATOR) last_child_source = node.children.last.source
return unless last_child_source.start_with?('.') ||
last_child_source.include?(File::SEPARATOR)
return if last_child_source.start_with?(':')
register_offense(node) register_offense(node)
end end

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop is used to identify usages of `where.take` and change them to use `find_by` instead. # Identifies usages of `where.take` and change them to use `find_by` instead.
# #
# And `where(...).first` can return different results from `find_by`. # And `where(...).first` can return different results from `find_by`.
# (They order records differently, so the "first" record can be different.) # (They order records differently, so the "first" record can be different.)

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces that `ActiveRecord#find` is used instead of # Enforces that `ActiveRecord#find` is used instead of
# `where.take!`, `find_by!`, and `find_by_id!` to retrieve a single record # `where.take!`, `find_by!`, and `find_by_id!` to retrieve a single record
# by primary key when you expect it to be found. # by primary key when you expect it to be found.
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop is used to identify usages of `all.each` and # Identifies usages of `all.each` and
# change them to use `all.find_each` instead. # change them to use `all.find_each` instead.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for the use of the has_and_belongs_to_many macro. # Checks for the use of the has_and_belongs_to_many macro.
# #
# @example # @example
# # bad # # bad

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for `has_many` or `has_one` associations that don't # Looks for `has_many` or `has_one` associations that don't
# specify a `:dependent` option. # specify a `:dependent` option.
# #
# It doesn't register an offense if `:through` or `dependent: nil` # It doesn't register an offense if `:through` or `dependent: nil`
@ -116,7 +116,7 @@ module RuboCop
def valid_options?(options) def valid_options?(options)
return false if options.nil? return false if options.nil?
options = options.first.children.first.pairs if options.first.kwsplat_type? options = extract_option_if_kwsplat(options)
return true unless options return true unless options
return true if options.any? do |o| return true if options.any? do |o|
@ -126,6 +126,14 @@ module RuboCop
false false
end end
def extract_option_if_kwsplat(options)
if options.first.kwsplat_type? && options.first.children.first.hash_type?
return options.first.children.first.pairs
end
options
end
def active_resource?(node) def active_resource?(node)
return false if node.nil? return false if node.nil?

View File

@ -3,14 +3,14 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for use of the helper methods which reference # Checks for use of the helper methods which reference
# instance variables. # instance variables.
# #
# Relying on instance variables makes it difficult to re-use helper # Relying on instance variables makes it difficult to re-use helper
# methods. # methods.
# #
# If it seems awkward to explicitly pass in each dependent # If it seems awkward to explicitly pass in each dependent
# variable, consider moving the behaviour elsewhere, for # variable, consider moving the behavior elsewhere, for
# example to a model, decorator or presenter. # example to a model, decorator or presenter.
# #
# Provided that a class inherits `ActionView::Helpers::FormBuilder`, # Provided that a class inherits `ActionView::Helpers::FormBuilder`,

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop is used to identify usages of http methods like `get`, `post`, # Identifies usages of http methods like `get`, `post`,
# `put`, `patch` without the usage of keyword arguments in your tests and # `put`, `patch` without the usage of keyword arguments in your tests and
# change them to use keyword args. This cop only applies to Rails >= 5. # change them to use keyword args. This cop only applies to Rails >= 5.
# If you are running Rails < 5 you should disable the # If you are running Rails < 5 you should disable the

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for places where I18n "lazy" lookup can be used. # Checks for places where I18n "lazy" lookup can be used.
# #
# @example # @example
# # en.yml # # en.yml

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for the use of `I18n.locale=` method. # Checks for the use of `I18n.locale=` method.
# #
# The `locale` attribute persists for the rest of the Ruby runtime, potentially causing # The `locale` attribute persists for the rest of the Ruby runtime, potentially causing
# unexpected behavior at a later time. # unexpected behavior at a later time.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that `if` and `only` (or `except`) are not used together # Checks that `if` and `only` (or `except`) are not used together
# as options of `skip_*` action filter. # as options of `skip_*` action filter.
# #
# The `if` option will be ignored when `if` and `only` are used together. # The `if` option will be ignored when `if` and `only` are used together.
@ -80,7 +80,7 @@ module RuboCop
def options_hash(options) def options_hash(options)
options.pairs options.pairs
.select { |pair| pair.key.sym_type? } .select { |pair| pair.key.sym_type? }
.map { |pair| [pair.key.value, pair] }.to_h .to_h { |pair| [pair.key.value, pair] }
end end
def if_and_only?(options) def if_and_only?(options)

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for uses of `each_with_object({}) { ... }`, # Looks for uses of `each_with_object({}) { ... }`,
# `map { ... }.to_h`, and `Hash[map { ... }]` that are transforming # `map { ... }.to_h`, and `Hash[map { ... }]` that are transforming
# an enumerable into a hash where the values are the original elements. # an enumerable into a hash where the values are the original elements.
# Rails provides the `index_by` method for this purpose. # Rails provides the `index_by` method for this purpose.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for uses of `each_with_object({}) { ... }`, # Looks for uses of `each_with_object({}) { ... }`,
# `map { ... }.to_h`, and `Hash[map { ... }]` that are transforming # `map { ... }.to_h`, and `Hash[map { ... }]` that are transforming
# an enumerable into a hash where the keys are the original elements. # an enumerable into a hash where the keys are the original elements.
# Rails provides the `index_with` method for this purpose. # Rails provides the `index_with` method for this purpose.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that Active Support's `inquiry` method is not used. # Checks that Active Support's `inquiry` method is not used.
# #
# @example # @example
# # bad - String#inquiry # # bad - String#inquiry

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for has_(one|many) and belongs_to associations where # Looks for has_(one|many) and belongs_to associations where
# Active Record can't automatically determine the inverse association # Active Record can't automatically determine the inverse association
# because of a scope or the options used. Using the blog with order scope # because of a scope or the options used. Using the blog with order scope
# example below, traversing the a Blog's association in both directions # example below, traversing the a Blog's association in both directions

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks that methods specified in the filter's `only` or # Checks that methods specified in the filter's `only` or
# `except` options are defined within the same class or module. # `except` options are defined within the same class or module.
# #
# @safety # @safety
@ -12,7 +12,7 @@ module RuboCop
# methods that are defined in other classes or modules, you should # methods that are defined in other classes or modules, you should
# define the filter in that class or module. # define the filter in that class or module.
# #
# If you rely on behaviour defined in the superclass actions, you must # If you rely on behavior defined in the superclass actions, you must
# remember to invoke `super` in the subclass actions. # remember to invoke `super` in the subclass actions.
# #
# @example # @example
@ -71,7 +71,7 @@ module RuboCop
# class ArticlesController < ContentController # class ArticlesController < ContentController
# before_action :load_article, only: [:update] # before_action :load_article, only: [:update]
# #
# # the cop requires this method, but it relies on behaviour defined # # the cop requires this method, but it relies on behavior defined
# # in the superclass, so needs to invoke `super` # # in the superclass, so needs to invoke `super`
# def update # def update
# super # super

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for calls to `link_to` that contain a # Checks for calls to `link_to` that contain a
# `target: '_blank'` but no `rel: 'noopener'`. This can be a security # `target: '_blank'` but no `rel: 'noopener'`. This can be a security
# risk as the loaded page will have control over the previous page # risk as the loaded page will have control over the previous page
# and could change its location for phishing purposes. # and could change its location for phishing purposes.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces that mailer names end with `Mailer` suffix. # Enforces that mailer names end with `Mailer` suffix.
# #
# Without the `Mailer` suffix it isn't immediately apparent what's a mailer # Without the `Mailer` suffix it isn't immediately apparent what's a mailer
# and which views are related to the mailer. # and which views are related to the mailer.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop identifies places where defining routes with `match` # Identifies places where defining routes with `match`
# can be replaced with a specific HTTP method. # can be replaced with a specific HTTP method.
# #
# Don't use `match` to define any routes unless there is a need to map multiple request types # Don't use `match` to define any routes unless there is a need to map multiple request types

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop makes sure that each migration file defines a migration class # Makes sure that each migration file defines a migration class
# whose name matches the file name. # whose name matches the file name.
# (e.g. `20220224111111_create_users.rb` should define `CreateUsers` class.) # (e.g. `20220224111111_create_users.rb` should define `CreateUsers` class.)
# #

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces the use of `collection.exclude?(obj)` # Enforces the use of `collection.exclude?(obj)`
# over `!collection.include?(obj)`. # over `!collection.include?(obj)`.
# #
# @safety # @safety

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for add_column call with NOT NULL constraint # Checks for add_column call with NOT NULL constraint
# in migration file. # in migration file.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for places where ordering by `id` column is used. # Checks for places where ordering by `id` column is used.
# #
# Don't use the `id` column for ordering. The sequence of ids is not guaranteed # Don't use the `id` column for ordering. The sequence of ids is not guaranteed
# to be in any particular order, despite often (incidentally) being chronological. # to be in any particular order, despite often (incidentally) being chronological.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for the use of output calls like puts and print # Checks for the use of output calls like puts and print
# #
# @safety # @safety
# This cop's autocorrection is unsafe because depending on the Rails log level configuration, # This cop's autocorrection is unsafe because depending on the Rails log level configuration,

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for the use of output safety calls like `html_safe`, # Checks for the use of output safety calls like `html_safe`,
# `raw`, and `safe_concat`. These methods do not escape content. They # `raw`, and `safe_concat`. These methods do not escape content. They
# simply return a SafeBuffer containing the content as is. Instead, # simply return a SafeBuffer containing the content as is. Instead,
# use `safe_join` to join content and escape it and concat to # use `safe_join` to join content and escape it and concat to

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces the use of `pick` over `pluck(...).first`. # Enforces the use of `pick` over `pluck(...).first`.
# #
# Using `pluck` followed by `first` creates an intermediate array, which # Using `pluck` followed by `first` creates an intermediate array, which
# `pick` avoids. When called on an Active Record relation, `pick` adds a # `pick` avoids. When called on an Active Record relation, `pick` adds a

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces the use of `pluck` over `map`. # Enforces the use of `pluck` over `map`.
# #
# `pluck` can be used instead of `map` to extract a single key from each # `pluck` can be used instead of `map` to extract a single key from each
# element in an enumerable. When called on an Active Record relation, it # element in an enumerable. When called on an Active Record relation, it

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop enforces the use of `ids` over `pluck(:id)` and `pluck(primary_key)`. # Enforces the use of `ids` over `pluck(:id)` and `pluck(primary_key)`.
# #
# @safety # @safety
# This cop is unsafe if the receiver object is not an Active Record object. # This cop is unsafe if the receiver object is not an Active Record object.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop identifies places where `pluck` is used in `where` query methods # Identifies places where `pluck` is used in `where` query methods
# and can be replaced with `select`. # and can be replaced with `select`.
# #
# Since `pluck` is an eager method and hits the database immediately, # Since `pluck` is an eager method and hits the database immediately,

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for correct grammar when using ActiveSupport's # Checks for correct grammar when using ActiveSupport's
# core extensions to the numeric classes. # core extensions to the numeric classes.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks code that can be written more easily using # Checks code that can be written more easily using
# `Object#presence` defined by Active Support. # `Object#presence` defined by Active Support.
# #
# @example # @example

View File

@ -3,13 +3,13 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for code that can be written with simpler conditionals # Checks for code that can be written with simpler conditionals
# using `Object#present?` defined by Active Support. # using `Object#present?` defined by Active Support.
# #
# Interaction with `Style/UnlessElse`: # Interaction with `Style/UnlessElse`:
# The configuration of `NotBlank` will not produce an offense in the # 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 inabled. This is
# to prevent interference between the auto-correction of the two cops. # to prevent interference between the autocorrection of the two cops.
# #
# @example NotNilAndNotEmpty: true (default) # @example NotNilAndNotEmpty: true (default)
# # Converts usages of `!nil? && !empty?` to `present?` # # Converts usages of `!nil? && !empty?` to `present?`

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for Rake tasks without the `:environment` task # Checks for Rake tasks without the `:environment` task
# dependency. The `:environment` task loads application code for other # dependency. The `:environment` task loads application code for other
# Rake tasks. Without it, tasks cannot make use of application code like # Rake tasks. Without it, tasks cannot make use of application code like
# models. # models.

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for the use of the `read_attribute` or `write_attribute` # Checks for the use of the `read_attribute` or `write_attribute`
# methods and recommends square brackets instead. # methods and recommends square brackets instead.
# #
# If an attribute is missing from the instance (for example, when # If an attribute is missing from the instance (for example, when

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop detects cases where the `:foreign_key` option on associations # Detects cases where the `:foreign_key` option on associations
# is redundant. # is redundant.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for redundant receiver in `with_options`. # Checks for redundant receiver in `with_options`.
# Receiver is implicit from Rails 4.2 or higher. # Receiver is implicit from Rails 4.2 or higher.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for redundant `travel_back` calls. # Checks for redundant `travel_back` calls.
# Since Rails 5.2, `travel_back` is automatically called at the end of the test. # Since Rails 5.2, `travel_back` is automatically called at the end of the test.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks if the value of the option `class_name`, in # Checks if the value of the option `class_name`, in
# the definition of a reflection is a string. # the definition of a reflection is a string.
# #
# @safety # @safety

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks whether constant value isn't relative date. # Checks whether constant value isn't relative date.
# Because the relative date will be evaluated only once. # Because the relative date will be evaluated only once.
# #
# @safety # @safety

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop looks for inline rendering within controller actions. # Looks for inline rendering within controller actions.
# #
# @example # @example
# # bad # # bad

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop identifies places where `render text:` can be # Identifies places where `render text:` can be
# replaced with `render plain:`. # replaced with `render plain:`.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for consistent uses of `request.referer` or # Checks for consistent uses of `request.referer` or
# `request.referrer`, depending on the cop's configuration. # `request.referrer`, depending on the cop's configuration.
# #
# @example EnforcedStyle: referer (default) # @example EnforcedStyle: referer (default)

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks for the usage of `require_dependency`. # Checks for the usage of `require_dependency`.
# #
# `require_dependency` is an obsolete method for Rails applications running in Zeitwerk mode. # `require_dependency` is an obsolete method for Rails applications running in Zeitwerk mode.
# In Zeitwerk mode, the semantics should match Ruby's and no need to be defensive with load order, # In Zeitwerk mode, the semantics should match Ruby's and no need to be defensive with load order,

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks whether the change method of the migration file is # Checks whether the change method of the migration file is
# reversible. # reversible.
# #
# @example # @example

View File

@ -3,7 +3,7 @@
module RuboCop module RuboCop
module Cop module Cop
module Rails module Rails
# This cop checks whether the migration implements # Checks whether the migration implements
# either a `change` method or both an `up` and a `down` # either a `change` method or both an `up` and a `down`
# method. # method.
# #
@ -49,15 +49,15 @@ module RuboCop
'both an `up` and a `down` method.' 'both an `up` and a `down` method.'
def_node_matcher :change_method?, <<~PATTERN def_node_matcher :change_method?, <<~PATTERN
[ #migration_class? `(def :change (args) _) ] `(def :change (args) _)
PATTERN PATTERN
def_node_matcher :up_and_down_methods?, <<~PATTERN def_node_matcher :up_and_down_methods?, <<~PATTERN
[ #migration_class? `(def :up (args) _) `(def :down (args) _) ] [`(def :up (args) _) `(def :down (args) _)]
PATTERN PATTERN
def on_class(node) def on_class(node)
return if change_method?(node) || up_and_down_methods?(node) return if !migration_class?(node) || change_method?(node) || up_and_down_methods?(node)
add_offense(node) add_offense(node)
end end

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