Sha256: d07b4292f14b6e04deea54c3e328c60c2b9eac1531d38c4c0efd10dcc4a45081

Contents?: true

Size: 596 Bytes

Versions: 2

Compression:

Stored size: 596 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Rails
      # This cop checks for the use of the read_attribute method.
      #
      # @example
      #
      #   # bad
      #   read_attributed(:attr)
      #
      #   # good
      #   self[:attr]
      class ReadAttribute < Cop
        MSG = 'Prefer self[:attribute] over read_attribute(:attribute).'

        def on_send(node)
          receiver, method_name, *_args = *node

          if receiver.nil? && method_name == :read_attribute
            add_offense(node, :selector)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.19.1 lib/rubocop/cop/rails/read_attribute.rb
rubocop-0.19.0 lib/rubocop/cop/rails/read_attribute.rb