Merge pull request #11325 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rails-2.10.0
build(deps): bump rubocop-rails from 2.9.1 to 2.10.0 in /Library/Homebrew
This commit is contained in:
commit
2f2df7156c
@ -30,7 +30,7 @@ GEM
|
||||
hpricot (0.8.6)
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
i18n (1.8.9)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
mechanize (2.8.0)
|
||||
addressable (~> 2.7)
|
||||
@ -123,10 +123,10 @@ GEM
|
||||
rubocop-performance (1.11.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.9.1)
|
||||
rubocop-rails (2.10.0)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-rspec (2.3.0)
|
||||
rubocop (~> 1.0)
|
||||
rubocop-ast (>= 1.1.0)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# DO NOT EDIT MANUALLY
|
||||
# This is an autogenerated file for types exported from the `i18n` gem.
|
||||
# Please instead update this file by running `tapioca sync`.
|
||||
# Please instead update this file by running `bin/tapioca sync`.
|
||||
|
||||
# typed: true
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# DO NOT EDIT MANUALLY
|
||||
# This is an autogenerated file for types exported from the `rubocop-rails` gem.
|
||||
# Please instead update this file by running `tapioca sync`.
|
||||
# Please instead update this file by running `bin/tapioca sync`.
|
||||
|
||||
# typed: true
|
||||
|
||||
@ -13,11 +13,13 @@ end
|
||||
module RuboCop::Cop::ActiveRecordHelper
|
||||
extend(::RuboCop::AST::NodePattern::Macros)
|
||||
|
||||
def active_record?(param0 = T.unsafe(nil)); end
|
||||
def external_dependency_checksum; end
|
||||
def find_belongs_to(param0); end
|
||||
def find_set_table_name(param0); end
|
||||
def foreign_key_of(belongs_to); end
|
||||
def in_where?(node); end
|
||||
def inherit_active_record_base?(node); end
|
||||
def resolve_relation_into_column(name:, class_node:, table:); end
|
||||
def schema; end
|
||||
def table_name(class_node); end
|
||||
@ -405,11 +407,14 @@ class RuboCop::Cop::Rails::ContentTag < ::RuboCop::Cop::Base
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
extend(::RuboCop::Cop::TargetRailsVersion)
|
||||
|
||||
def on_new_investigation; end
|
||||
def on_send(node); end
|
||||
|
||||
private
|
||||
|
||||
def allowed_argument?(argument); end
|
||||
def autocorrect(corrector, node); end
|
||||
def corrected_ancestor?(node); end
|
||||
def correction_range(node); end
|
||||
def method_name?(node); end
|
||||
end
|
||||
@ -513,6 +518,7 @@ RuboCop::Cop::Rails::DelegateAllowBlank::MSG = T.let(T.unsafe(nil), String)
|
||||
RuboCop::Cop::Rails::DelegateAllowBlank::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::Rails::DynamicFindBy < ::RuboCop::Cop::Base
|
||||
include(::RuboCop::Cop::ActiveRecordHelper)
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
|
||||
def on_csend(node); end
|
||||
@ -593,6 +599,21 @@ RuboCop::Cop::Rails::EnvironmentComparison::RESTRICT_ON_SEND = T.let(T.unsafe(ni
|
||||
|
||||
RuboCop::Cop::Rails::EnvironmentComparison::SYM_MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::Rails::EnvironmentVariableAccess < ::RuboCop::Cop::Base
|
||||
def env_read?(param0); end
|
||||
def env_write?(param0); end
|
||||
def on_const(node); end
|
||||
|
||||
private
|
||||
|
||||
def allow_reads?; end
|
||||
def allow_writes?; end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::EnvironmentVariableAccess::READ_MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::EnvironmentVariableAccess::WRITE_MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::Rails::Exit < ::RuboCop::Cop::Base
|
||||
include(::RuboCop::Cop::ConfigurableEnforcedStyle)
|
||||
|
||||
@ -677,6 +698,7 @@ RuboCop::Cop::Rails::FindById::MSG = T.let(T.unsafe(nil), String)
|
||||
RuboCop::Cop::Rails::FindById::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::Rails::FindEach < ::RuboCop::Cop::Base
|
||||
include(::RuboCop::Cop::ActiveRecordHelper)
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
|
||||
def on_send(node); end
|
||||
@ -702,17 +724,20 @@ RuboCop::Cop::Rails::HasAndBelongsToMany::RESTRICT_ON_SEND = T.let(T.unsafe(nil)
|
||||
|
||||
class RuboCop::Cop::Rails::HasManyOrHasOneDependent < ::RuboCop::Cop::Base
|
||||
def active_resource_class?(param0); end
|
||||
def association_extension_block?(param0 = T.unsafe(nil)); end
|
||||
def association_with_options?(param0 = T.unsafe(nil)); end
|
||||
def association_without_options?(param0 = T.unsafe(nil)); end
|
||||
def dependent_option?(param0 = T.unsafe(nil)); end
|
||||
def on_send(node); end
|
||||
def present_option?(param0 = T.unsafe(nil)); end
|
||||
def readonly?(param0 = T.unsafe(nil)); end
|
||||
def with_options_block(param0 = T.unsafe(nil)); end
|
||||
|
||||
private
|
||||
|
||||
def active_resource?(node); end
|
||||
def contain_valid_options_in_with_options_block?(node); end
|
||||
def readonly_model?(node); end
|
||||
def valid_options?(options); end
|
||||
def valid_options_in_with_options_block?(node); end
|
||||
end
|
||||
@ -734,6 +759,7 @@ end
|
||||
RuboCop::Cop::Rails::HelperInstanceVariable::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::Rails::HttpPositionalArguments < ::RuboCop::Cop::Base
|
||||
include(::RuboCop::Cop::RangeHelp)
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
extend(::RuboCop::Cop::TargetRailsVersion)
|
||||
|
||||
@ -747,6 +773,7 @@ class RuboCop::Cop::Rails::HttpPositionalArguments < ::RuboCop::Cop::Base
|
||||
def correction(node); end
|
||||
def correction_template(node); end
|
||||
def format_arg?(node); end
|
||||
def highlight_range(node); end
|
||||
def needs_conversion?(data); end
|
||||
def special_keyword_arg?(node); end
|
||||
end
|
||||
@ -1280,8 +1307,14 @@ class RuboCop::Cop::Rails::ReflectionClassName < ::RuboCop::Cop::Base
|
||||
def association_with_reflection(param0 = T.unsafe(nil)); end
|
||||
def on_send(node); end
|
||||
def reflection_class_name(param0 = T.unsafe(nil)); end
|
||||
|
||||
private
|
||||
|
||||
def reflection_class_value?(class_value); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::ReflectionClassName::ALLOWED_REFLECTION_CLASS_TYPES = T.let(T.unsafe(nil), Array)
|
||||
|
||||
RuboCop::Cop::Rails::ReflectionClassName::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::ReflectionClassName::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
@ -1318,7 +1351,6 @@ class RuboCop::Cop::Rails::RelativeDateConstant < ::RuboCop::Cop::Base
|
||||
def on_masgn(node); end
|
||||
def on_or_asgn(node); end
|
||||
def relative_date?(param0 = T.unsafe(nil)); end
|
||||
def relative_date_assignment?(param0 = T.unsafe(nil)); end
|
||||
def relative_date_or_assignment?(param0 = T.unsafe(nil)); end
|
||||
|
||||
private
|
||||
@ -1326,10 +1358,13 @@ class RuboCop::Cop::Rails::RelativeDateConstant < ::RuboCop::Cop::Base
|
||||
def autocorrect(corrector, node); end
|
||||
def message(method_name); end
|
||||
def offense_range(name, value); end
|
||||
def relative_date_method?(method_name); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::RelativeDateConstant::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::RelativeDateConstant::RELATIVE_DATE_METHODS = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::Rails::RenderInline < ::RuboCop::Cop::Base
|
||||
def on_send(node); end
|
||||
def render_with_inline_option?(param0 = T.unsafe(nil)); end
|
||||
@ -1373,6 +1408,17 @@ RuboCop::Cop::Rails::RequestReferer::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::RequestReferer::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::Rails::RequireDependency < ::RuboCop::Cop::Base
|
||||
extend(::RuboCop::Cop::TargetRailsVersion)
|
||||
|
||||
def on_send(node); end
|
||||
def require_dependency_call?(param0 = T.unsafe(nil)); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::RequireDependency::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::RequireDependency::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::Rails::ReversibleMigration < ::RuboCop::Cop::Base
|
||||
def change_table_call(param0 = T.unsafe(nil)); end
|
||||
def drop_table_call(param0 = T.unsafe(nil)); end
|
||||
@ -1403,6 +1449,15 @@ end
|
||||
|
||||
RuboCop::Cop::Rails::ReversibleMigration::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::Rails::ReversibleMigrationMethodDefinition < ::RuboCop::Cop::Base
|
||||
def change_method?(param0 = T.unsafe(nil)); end
|
||||
def migration_class?(param0 = T.unsafe(nil)); end
|
||||
def on_class(node); end
|
||||
def up_and_down_methods?(param0 = T.unsafe(nil)); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::ReversibleMigrationMethodDefinition::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
class RuboCop::Cop::Rails::SafeNavigation < ::RuboCop::Cop::Base
|
||||
include(::RuboCop::Cop::RangeHelp)
|
||||
extend(::RuboCop::Cop::AutoCorrector)
|
||||
@ -1414,6 +1469,10 @@ class RuboCop::Cop::Rails::SafeNavigation < ::RuboCop::Cop::Base
|
||||
|
||||
def autocorrect(corrector, node); end
|
||||
def replacement(method, params); end
|
||||
|
||||
class << self
|
||||
def autocorrect_incompatible_with; end
|
||||
end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::SafeNavigation::MSG = T.let(T.unsafe(nil), String)
|
||||
@ -1552,6 +1611,7 @@ class RuboCop::Cop::Rails::TimeZone < ::RuboCop::Cop::Base
|
||||
private
|
||||
|
||||
def acceptable_methods(klass, method_name, node); end
|
||||
def attach_timezone_specifier?(date); end
|
||||
def autocorrect(corrector, node); end
|
||||
def autocorrect_time_new(node, corrector); end
|
||||
def build_message(klass, method_name, node); end
|
||||
@ -1582,6 +1642,17 @@ RuboCop::Cop::Rails::TimeZone::MSG_ACCEPTABLE = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::TimeZone::MSG_LOCALTIME = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::TimeZone::TIMEZONE_SPECIFIER = T.let(T.unsafe(nil), Regexp)
|
||||
|
||||
class RuboCop::Cop::Rails::TimeZoneAssignment < ::RuboCop::Cop::Base
|
||||
def on_send(node); end
|
||||
def time_zone_assignement?(param0 = T.unsafe(nil)); end
|
||||
end
|
||||
|
||||
RuboCop::Cop::Rails::TimeZoneAssignment::MSG = T.let(T.unsafe(nil), String)
|
||||
|
||||
RuboCop::Cop::Rails::TimeZoneAssignment::RESTRICT_ON_SEND = T.let(T.unsafe(nil), Array)
|
||||
|
||||
class RuboCop::Cop::Rails::UniqBeforePluck < ::RuboCop::Cop::Base
|
||||
include(::RuboCop::Cop::ConfigurableEnforcedStyle)
|
||||
include(::RuboCop::Cop::RangeHelp)
|
||||
@ -4,7 +4,7 @@ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
||||
ruby_version = RbConfig::CONFIG["ruby_version"]
|
||||
path = File.expand_path('..', __FILE__)
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/concurrent-ruby-1.1.8/lib/concurrent-ruby"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.8.9/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.8.10/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.14.4/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tzinfo-2.0.4/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/zeitwerk-2.4.2/lib"
|
||||
@ -81,7 +81,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.13.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.9.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.10.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.3.0/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.1/lib"
|
||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.0/lib"
|
||||
|
||||
@ -49,7 +49,7 @@ module I18n
|
||||
catch(:exception) do
|
||||
result = super(fallback, key, fallback_options)
|
||||
unless result.nil?
|
||||
on_fallback(locale, fallback, key, options) if locale != fallback
|
||||
on_fallback(locale, fallback, key, options) if locale.to_s != fallback.to_s
|
||||
return result
|
||||
end
|
||||
end
|
||||
@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module I18n
|
||||
VERSION = "1.8.9"
|
||||
VERSION = "1.8.10"
|
||||
end
|
||||
@ -17,6 +17,27 @@ AllCops:
|
||||
# as the default.
|
||||
TargetRailsVersion: ~
|
||||
|
||||
Lint/NumberConversion:
|
||||
# Add Rails' duration methods to the ignore list for `Lint/NumberConversion`
|
||||
# so that calling `to_i` on one of these does not register an offense.
|
||||
# See: https://github.com/rubocop/rubocop/issues/8950
|
||||
IgnoredMethods:
|
||||
- ago
|
||||
- from_now
|
||||
- second
|
||||
- seconds
|
||||
- minute
|
||||
- minutes
|
||||
- hour
|
||||
- hours
|
||||
- day
|
||||
- days
|
||||
- week
|
||||
- weeks
|
||||
- fortnight
|
||||
- fortnights
|
||||
- in_milliseconds
|
||||
|
||||
Rails/ActionFilter:
|
||||
Description: 'Enforces consistent use of action filter methods.'
|
||||
Enabled: true
|
||||
@ -128,8 +149,9 @@ Rails/BelongsTo:
|
||||
Rails/Blank:
|
||||
Description: 'Enforces use of `blank?`.'
|
||||
Enabled: true
|
||||
SafeAutoCorrect: false
|
||||
VersionAdded: '0.48'
|
||||
VersionChanged: '0.67'
|
||||
VersionChanged: '2.10'
|
||||
# Convert usages of `nil? || empty?` to `blank?`
|
||||
NilOrEmpty: true
|
||||
# Convert usages of `!present?` to `blank?`
|
||||
@ -207,8 +229,9 @@ Rails/DynamicFindBy:
|
||||
Description: 'Use `find_by` instead of dynamic `find_by_*`.'
|
||||
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
||||
Enabled: true
|
||||
Safe: false
|
||||
VersionAdded: '0.44'
|
||||
VersionChanged: '2.6'
|
||||
VersionChanged: '2.10'
|
||||
# The `Whitelist` has been deprecated, Please use `AllowedMethods` instead.
|
||||
Whitelist:
|
||||
- find_by_sql
|
||||
@ -237,6 +260,18 @@ Rails/EnvironmentComparison:
|
||||
Enabled: true
|
||||
VersionAdded: '0.52'
|
||||
|
||||
Rails/EnvironmentVariableAccess:
|
||||
Description: 'Do not access `ENV` directly after initialization.'
|
||||
Enabled: pending
|
||||
VersionAdded: '2.10'
|
||||
Include:
|
||||
- app/**/*.rb
|
||||
- lib/**/*.rb
|
||||
Exclude:
|
||||
- lib/**/*.rake
|
||||
AllowReads: false
|
||||
AllowWrites: false
|
||||
|
||||
Rails/Exit:
|
||||
Description: >-
|
||||
Favor `fail`, `break`, `return`, etc. over `exit` in
|
||||
@ -540,7 +575,9 @@ Rails/RedundantReceiverInWithOptions:
|
||||
Rails/ReflectionClassName:
|
||||
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
|
||||
Enabled: true
|
||||
Safe: false
|
||||
VersionAdded: '0.64'
|
||||
VersionChanged: '2.10'
|
||||
|
||||
Rails/RefuteMethods:
|
||||
Description: 'Use `assert_not` methods instead of `refute` methods.'
|
||||
@ -583,6 +620,12 @@ Rails/RequestReferer:
|
||||
- referer
|
||||
- referrer
|
||||
|
||||
Rails/RequireDependency:
|
||||
Description: 'Do not use `require_dependency` when running in Zeitwerk mode. `require_dependency` is for autoloading in classic mode.'
|
||||
Reference: 'https://guides.rubyonrails.org/autoloading_and_reloading_constants.html'
|
||||
Enabled: false
|
||||
VersionAdded: '2.10'
|
||||
|
||||
Rails/ReversibleMigration:
|
||||
Description: 'Checks whether the change method of the migration file is reversible.'
|
||||
StyleGuide: 'https://rails.rubystyle.guide#reversible-migration'
|
||||
@ -592,6 +635,13 @@ Rails/ReversibleMigration:
|
||||
Include:
|
||||
- db/migrate/*.rb
|
||||
|
||||
Rails/ReversibleMigrationMethodDefinition:
|
||||
Description: 'Checks whether the migration implements either a `change` method or both an `up` and a `down` method.'
|
||||
Enabled: false
|
||||
VersionAdded: '2.10'
|
||||
include:
|
||||
- db/migrate/*.rb
|
||||
|
||||
Rails/SafeNavigation:
|
||||
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`."
|
||||
Enabled: true
|
||||
@ -687,13 +737,24 @@ Rails/TimeZone:
|
||||
Enabled: true
|
||||
Safe: false
|
||||
VersionAdded: '0.30'
|
||||
VersionChanged: '0.68'
|
||||
VersionChanged: '2.10'
|
||||
# The value `strict` means that `Time` should be used with `zone`.
|
||||
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
|
||||
EnforcedStyle: flexible
|
||||
SupportedStyles:
|
||||
- strict
|
||||
- flexible
|
||||
Exclude:
|
||||
- '**/*.gemspec'
|
||||
|
||||
Rails/TimeZoneAssignment:
|
||||
Description: 'Prefer the usage of `Time.use_zone` instead of manually updating `Time.zone` value.'
|
||||
Reference: 'https://thoughtbot.com/blog/its-about-time-zones'
|
||||
Enabled: 'pending'
|
||||
VersionAdded: '2.10'
|
||||
Include:
|
||||
- spec/**/*.rb
|
||||
- test/**/*.rb
|
||||
|
||||
Rails/UniqBeforePluck:
|
||||
Description: 'Prefer the use of uniq or distinct before pluck.'
|
||||
@ -735,17 +796,20 @@ Rails/WhereEquals:
|
||||
Description: 'Pass conditions to `where` as a hash instead of manually constructing SQL.'
|
||||
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
||||
Enabled: 'pending'
|
||||
SafeAutoCorrect: false
|
||||
VersionAdded: '2.9'
|
||||
VersionChanged: '2.10'
|
||||
|
||||
Rails/WhereExists:
|
||||
Description: 'Prefer `exists?(...)` over `where(...).exists?`.'
|
||||
Enabled: 'pending'
|
||||
SafeAutoCorrect: false
|
||||
EnforcedStyle: exists
|
||||
SupportedStyles:
|
||||
- exists
|
||||
- where
|
||||
VersionAdded: '2.7'
|
||||
VersionChanged: '2.8'
|
||||
VersionChanged: '2.10'
|
||||
|
||||
Rails/WhereNot:
|
||||
Description: 'Use `where.not(...)` instead of manually constructing negated SQL in `where`.'
|
||||
7
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rails-2.10.0/config/obsoletion.yml
vendored
Normal file
7
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rails-2.10.0/config/obsoletion.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
#
|
||||
# Configuration for obsoletion.
|
||||
#
|
||||
# See: https://docs.rubocop.org/rubocop/extensions.html#config-obsoletions
|
||||
#
|
||||
extracted:
|
||||
Rails/*: ~
|
||||
@ -8,6 +8,13 @@ module RuboCop
|
||||
|
||||
WHERE_METHODS = %i[where rewhere].freeze
|
||||
|
||||
def_node_matcher :active_record?, <<~PATTERN
|
||||
{
|
||||
(const nil? :ApplicationRecord)
|
||||
(const (const nil? :ActiveRecord) :Base)
|
||||
}
|
||||
PATTERN
|
||||
|
||||
def_node_search :find_set_table_name, <<~PATTERN
|
||||
(send self :table_name= {str sym})
|
||||
PATTERN
|
||||
@ -16,6 +23,10 @@ module RuboCop
|
||||
(send nil? :belongs_to {str sym} ...)
|
||||
PATTERN
|
||||
|
||||
def inherit_active_record_base?(node)
|
||||
node.each_ancestor(:class).any? { |class_node| active_record?(class_node.parent_class) }
|
||||
end
|
||||
|
||||
def external_dependency_checksum
|
||||
return @external_dependency_checksum if defined?(@external_dependency_checksum)
|
||||
|
||||
@ -75,7 +75,7 @@ module RuboCop
|
||||
def on_send(node)
|
||||
default_attribute(node) do |attribute|
|
||||
value = attribute.children.last
|
||||
return unless TYPE_OFFENDERS.any? { |type| value.type == type }
|
||||
return unless TYPE_OFFENDERS.any?(value.type)
|
||||
|
||||
add_offense(value) do |corrector|
|
||||
expression = default_attribute(node).children.last
|
||||
@ -68,7 +68,7 @@ module RuboCop
|
||||
RESTRICT_ON_SEND = %i[belongs_to].freeze
|
||||
|
||||
def_node_matcher :match_belongs_to_with_options, <<~PATTERN
|
||||
(send _ :belongs_to _
|
||||
(send _ :belongs_to ...
|
||||
(hash <$(pair (sym :required) ${true false}) ...>)
|
||||
)
|
||||
PATTERN
|
||||
@ -6,6 +6,10 @@ module RuboCop
|
||||
# This cop checks for code that can be written with simpler conditionals
|
||||
# using `Object#blank?` defined by Active Support.
|
||||
#
|
||||
# This cop is marked as unsafe auto-correction, because `' '.empty?` returns false,
|
||||
# but `' '.blank?` returns true. Therefore, auto-correction is not compatible
|
||||
# if the receiver is a non-empty blank string, tab, or newline meta characters.
|
||||
#
|
||||
# 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
|
||||
@ -28,19 +28,34 @@ module RuboCop
|
||||
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 unless first_argument
|
||||
|
||||
return if first_argument.variable? || first_argument.send_type? || first_argument.const_type?
|
||||
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)
|
||||
@ -32,13 +32,14 @@ module RuboCop
|
||||
# # good
|
||||
# Gem::Specification.find_by_name('backend').gem_dir
|
||||
class DynamicFindBy < Base
|
||||
include ActiveRecordHelper
|
||||
extend AutoCorrector
|
||||
|
||||
MSG = 'Use `%<static_name>s` instead of dynamic `%<method>s`.'
|
||||
METHOD_PATTERN = /^find_by_(.+?)(!)?$/.freeze
|
||||
|
||||
def on_send(node)
|
||||
return if 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)
|
||||
@ -0,0 +1,67 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RuboCop
|
||||
module Cop
|
||||
module Rails
|
||||
# This cop looks for direct access to environment variables through the
|
||||
# `ENV` variable within the application code. This can lead to runtime
|
||||
# errors due to misconfiguration that could have been discovered at boot
|
||||
# time if the environment variables were loaded as part of initialization
|
||||
# and copied into the application's configuration or secrets. The cop can
|
||||
# be configured to allow either reads or writes if required.
|
||||
#
|
||||
# @example
|
||||
# # good
|
||||
# Rails.application.config.foo
|
||||
# Rails.application.config.x.foo.bar
|
||||
# Rails.application.secrets.foo
|
||||
# Rails.application.config.foo = "bar"
|
||||
#
|
||||
# @example AllowReads: false (default)
|
||||
# # bad
|
||||
# ENV["FOO"]
|
||||
# ENV.fetch("FOO")
|
||||
#
|
||||
# @example AllowReads: true
|
||||
# # good
|
||||
# ENV["FOO"]
|
||||
# ENV.fetch("FOO")
|
||||
#
|
||||
# @example AllowWrites: false (default)
|
||||
# # bad
|
||||
# ENV["FOO"] = "bar"
|
||||
#
|
||||
# @example AllowWrites: true
|
||||
# # good
|
||||
# ENV["FOO"] = "bar"
|
||||
class EnvironmentVariableAccess < Base
|
||||
READ_MSG = 'Do not read from `ENV` directly post initialization.'
|
||||
WRITE_MSG = 'Do not write to `ENV` directly post initialization.'
|
||||
|
||||
def on_const(node)
|
||||
add_offense(node, message: READ_MSG) if env_read?(node) && !allow_reads?
|
||||
add_offense(node, message: WRITE_MSG) if env_write?(node) && !allow_writes?
|
||||
end
|
||||
|
||||
def_node_search :env_read?, <<~PATTERN
|
||||
^(send (const {cbase nil?} :ENV) !:[]= ...)
|
||||
PATTERN
|
||||
|
||||
def_node_search :env_write?, <<~PATTERN
|
||||
{^(indexasgn (const {cbase nil?} :ENV) ...)
|
||||
^(send (const {cbase nil?} :ENV) :[]= ...)}
|
||||
PATTERN
|
||||
|
||||
private
|
||||
|
||||
def allow_reads?
|
||||
cop_config['AllowReads'] == true
|
||||
end
|
||||
|
||||
def allow_writes?
|
||||
cop_config['AllowWrites'] == true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -29,10 +29,8 @@ module RuboCop
|
||||
include ConfigurableEnforcedStyle
|
||||
include RangeHelp
|
||||
|
||||
MSG_SLASHES = 'Please use `Rails.root.join(\'path/to\')` ' \
|
||||
'instead.'
|
||||
MSG_ARGUMENTS = 'Please use `Rails.root.join(\'path\', \'to\')` ' \
|
||||
'instead.'
|
||||
MSG_SLASHES = 'Prefer `Rails.root.join(\'path/to\')`.'
|
||||
MSG_ARGUMENTS = 'Prefer `Rails.root.join(\'path\', \'to\')`.'
|
||||
RESTRICT_ON_SEND = %i[join].freeze
|
||||
|
||||
def_node_matcher :file_join_nodes?, <<~PATTERN
|
||||
@ -17,6 +17,7 @@ module RuboCop
|
||||
# # good
|
||||
# User.order(:foo).each
|
||||
class FindEach < Base
|
||||
include ActiveRecordHelper
|
||||
extend AutoCorrector
|
||||
|
||||
MSG = 'Use `find_each` instead of `each`.'
|
||||
@ -30,6 +31,7 @@ module RuboCop
|
||||
def on_send(node)
|
||||
return unless node.receiver&.send_type?
|
||||
return unless SCOPE_METHODS.include?(node.receiver.method_name)
|
||||
return if node.receiver.receiver.nil? && !inherit_active_record_base?(node)
|
||||
return if ignored?(node)
|
||||
|
||||
range = node.loc.selector
|
||||
@ -5,7 +5,9 @@ module RuboCop
|
||||
module Rails
|
||||
# This cop looks for `has_many` or `has_one` associations that don't
|
||||
# specify a `:dependent` option.
|
||||
# It doesn't register an offense if `:through` option was specified.
|
||||
#
|
||||
# It doesn't register an offense if `:through` or `dependent: nil`
|
||||
# is specified, or if the model is read-only.
|
||||
#
|
||||
# @example
|
||||
# # bad
|
||||
@ -18,8 +20,18 @@ module RuboCop
|
||||
# class User < ActiveRecord::Base
|
||||
# has_many :comments, dependent: :restrict_with_exception
|
||||
# has_one :avatar, dependent: :destroy
|
||||
# has_many :articles, dependent: nil
|
||||
# has_many :patients, through: :appointments
|
||||
# end
|
||||
#
|
||||
# class User < ActiveRecord::Base
|
||||
# has_many :comments
|
||||
# has_one :avatar
|
||||
#
|
||||
# def readonly?
|
||||
# true
|
||||
# end
|
||||
# end
|
||||
class HasManyOrHasOneDependent < Base
|
||||
MSG = 'Specify a `:dependent` option.'
|
||||
RESTRICT_ON_SEND = %i[has_many has_one].freeze
|
||||
@ -37,7 +49,7 @@ module RuboCop
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :dependent_option?, <<~PATTERN
|
||||
(pair (sym :dependent) !nil)
|
||||
(pair (sym :dependent) {!nil (nil)})
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :present_option?, <<~PATTERN
|
||||
@ -51,8 +63,20 @@ module RuboCop
|
||||
(args) ...)
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :association_extension_block?, <<~PATTERN
|
||||
(block
|
||||
(send nil? :has_many _)
|
||||
(args) ...)
|
||||
PATTERN
|
||||
|
||||
def_node_matcher :readonly?, <<~PATTERN
|
||||
(def :readonly?
|
||||
(args)
|
||||
(true))
|
||||
PATTERN
|
||||
|
||||
def on_send(node)
|
||||
return if active_resource?(node.parent)
|
||||
return if active_resource?(node.parent) || readonly_model?(node)
|
||||
return if !association_without_options?(node) && valid_options?(association_with_options?(node))
|
||||
return if valid_options_in_with_options_block?(node)
|
||||
|
||||
@ -61,10 +85,16 @@ module RuboCop
|
||||
|
||||
private
|
||||
|
||||
def readonly_model?(node)
|
||||
return false unless (parent = node.parent)
|
||||
|
||||
parent.each_descendant(:def).any? { |def_node| readonly?(def_node) }
|
||||
end
|
||||
|
||||
def valid_options_in_with_options_block?(node)
|
||||
return true unless node.parent
|
||||
|
||||
n = node.parent.begin_type? ? node.parent.parent : node.parent
|
||||
n = node.parent.begin_type? || association_extension_block?(node.parent) ? node.parent.parent : node.parent
|
||||
|
||||
contain_valid_options_in_with_options_block?(n)
|
||||
end
|
||||
@ -18,6 +18,7 @@ module RuboCop
|
||||
# get :new, params: { user_id: 1 }
|
||||
# get :new, **options
|
||||
class HttpPositionalArguments < Base
|
||||
include RangeHelp
|
||||
extend AutoCorrector
|
||||
extend TargetRailsVersion
|
||||
|
||||
@ -44,7 +45,7 @@ module RuboCop
|
||||
|
||||
message = format(MSG, verb: node.method_name)
|
||||
|
||||
add_offense(node.loc.selector, message: message) do |corrector|
|
||||
add_offense(highlight_range(node), message: message) do |corrector|
|
||||
# given a pre Rails 5 method: get :new, {user_id: @user.id}, {}
|
||||
#
|
||||
# @return lambda of auto correct procedure
|
||||
@ -80,6 +81,12 @@ module RuboCop
|
||||
node.sym_type? && node.value == :format
|
||||
end
|
||||
|
||||
def highlight_range(node)
|
||||
_http_path, *data = *node.arguments
|
||||
|
||||
range_between(data.first.source_range.begin_pos, data.last.source_range.end_pos)
|
||||
end
|
||||
|
||||
def convert_hash_data(data, type)
|
||||
return '' if data.hash_type? && data.empty?
|
||||
|
||||
@ -79,7 +79,11 @@ module RuboCop
|
||||
opening_quote = offence_node.children.last.source[0]
|
||||
closing_quote = opening_quote == ':' ? '' : opening_quote
|
||||
new_rel_exp = ", rel: #{opening_quote}noopener#{closing_quote}"
|
||||
range = send_node.arguments.last.source_range
|
||||
range = if (last_argument = send_node.last_argument).hash_type?
|
||||
last_argument.pairs.last.source_range
|
||||
else
|
||||
last_argument.source_range
|
||||
end
|
||||
|
||||
corrector.insert_after(range, new_rel_exp)
|
||||
end
|
||||
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