Sha256: c3bace0df9c1e87f392357a95391b86f00b23d7cc5de3e7072727e7ea54b1b4f

Contents?: true

Size: 497 Bytes

Versions: 3

Compression:

Stored size: 497 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)
          convention(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

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.15.0 lib/rubocop/cop/style/attr.rb
rubocop-0.14.1 lib/rubocop/cop/style/attr.rb
rubocop-0.14.0 lib/rubocop/cop/style/attr.rb