Sha256: 082db070a7f216d4c5a53ebef0288702827ef2091223ec30dd261ec0a2f04f7a

Contents?: true

Size: 498 Bytes

Versions: 6

Compression:

Stored size: 498 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks for uses of Module#attr.
      class Attr < Cop
        MSG = 'Do not use `attr`. Use `attr_reader` instead.'

        def on_send(node)
          add_offense(node, :selector) if command?(:attr, node)
        end

        def autocorrect(node)
          @corrections << lambda do |corrector|
            corrector.replace(node.loc.selector, 'attr_reader')
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-0.22.0 lib/rubocop/cop/style/attr.rb
rubocop-0.21.0 lib/rubocop/cop/style/attr.rb
rubocop-0.20.1 lib/rubocop/cop/style/attr.rb
rubocop-0.20.0 lib/rubocop/cop/style/attr.rb
rubocop-0.19.1 lib/rubocop/cop/style/attr.rb
rubocop-0.19.0 lib/rubocop/cop/style/attr.rb