Sha256: dbbb670d6eed37903c752e6c82bce8f6bac3533014c60cf69bd079744a0b6558

Contents?: true

Size: 944 Bytes

Versions: 33

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Rails
      # Checks that Active Support's `inquiry` method is not used.
      #
      # @example
      #   # bad - String#inquiry
      #   ruby = 'two'.inquiry
      #   ruby.two?
      #
      #   # good
      #   ruby = 'two'
      #   ruby == 'two'
      #
      #   # bad - Array#inquiry
      #   pets = %w(cat dog).inquiry
      #   pets.gopher?
      #
      #   # good
      #   pets = %w(cat dog)
      #   pets.include? 'cat'
      #
      class Inquiry < Base
        MSG = "Prefer Ruby's comparison operators over Active Support's `inquiry`."
        RESTRICT_ON_SEND = %i[inquiry].freeze

        def on_send(node)
          return unless node.arguments.empty?
          return unless (receiver = node.receiver)
          return if !receiver.str_type? && !receiver.array_type?

          add_offense(node.loc.selector)
        end
      end
    end
  end
end

Version data entries

33 entries across 30 versions & 5 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails/inquiry.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails/inquiry.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails/inquiry.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails/inquiry.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rails-2.20.0/lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.22.2 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.22.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.22.0 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.21.2 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.21.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.21.0 lib/rubocop/cop/rails/inquiry.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/rubocop-rails-2.20.2/lib/rubocop/cop/rails/inquiry.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/rubocop-rails-2.19.1/lib/rubocop/cop/rails/inquiry.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/rubocop-rails-2.20.2/lib/rubocop/cop/rails/inquiry.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rails-2.15.2/lib/rubocop/cop/rails/inquiry.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rails-2.20.0/lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.20.2 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.20.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.20.0 lib/rubocop/cop/rails/inquiry.rb
fablicop-1.10.2 vendor/bundle/ruby/3.2.0/gems/rubocop-rails-2.19.1/lib/rubocop/cop/rails/inquiry.rb