Sha256: 43c15db5e83f960550b60653d5d3329834a3b06922e782d9c6d235fa7179620e

Contents?: true

Size: 498 Bytes

Versions: 4

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_offence(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

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.18.1 lib/rubocop/cop/style/attr.rb
rubocop-0.18.0 lib/rubocop/cop/style/attr.rb
rubocop-0.17.0 lib/rubocop/cop/style/attr.rb
rubocop-0.16.0 lib/rubocop/cop/style/attr.rb