Sha256: 9dc617fdc9a3351e235facfa0296a83c36b03503413c4922e7941be4be4826f8

Contents?: true

Size: 581 Bytes

Versions: 14

Compression:

Stored size: 581 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)
          return unless command?(:attr, node)
          _receiver, _method_name, *args = *node
          add_offense(node, :selector) if args.any?
        end

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

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/attr.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/style/attr.rb
rubocop-0.30.1 lib/rubocop/cop/style/attr.rb
rubocop-0.30.0 lib/rubocop/cop/style/attr.rb
rubocop-0.29.1 lib/rubocop/cop/style/attr.rb
rubocop-0.29.0 lib/rubocop/cop/style/attr.rb
rubocop-0.28.0 lib/rubocop/cop/style/attr.rb
rubocop-0.27.1 lib/rubocop/cop/style/attr.rb
rubocop-0.27.0 lib/rubocop/cop/style/attr.rb
rubocop-0.26.1 lib/rubocop/cop/style/attr.rb
rubocop-0.26.0 lib/rubocop/cop/style/attr.rb
rubocop-0.25.0 lib/rubocop/cop/style/attr.rb
rubocop-0.24.1 lib/rubocop/cop/style/attr.rb
rubocop-0.24.0 lib/rubocop/cop/style/attr.rb