Sha256: f0acee65ef3a11091822905e59e2846ae07dbedea56bed557ea20dbbfcaaec1a

Contents?: true

Size: 953 Bytes

Versions: 21

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Rails
      # This cop 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

21 entries across 21 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rails-2.14.2/lib/rubocop/cop/rails/inquiry.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rails-2.14.2/lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.14.2 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.14.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.14.0 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.13.2 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.13.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.13.0 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.12.4 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.12.3 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.12.2 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.12.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.12.0 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.11.3 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.11.2 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.11.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.11.0 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.10.1 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.10.0 lib/rubocop/cop/rails/inquiry.rb
rubocop-rails-2.9.1 lib/rubocop/cop/rails/inquiry.rb