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