Sha256: 491ef653f88d9c37cb72a56188b966ef5b31a93a6e8fa4601891df573bf61068
Contents?: true
Size: 638 Bytes
Versions: 3
Compression:
Stored size: 638 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class TrivialAccessors < Cop MSG = 'Use attr_%s to define trivial %s methods.' def on_def(node) method_name, args, body = *node kind = if body.type == :ivar 'reader' elsif args.children.size == 1 && body.type == :ivasgn && body.children[1].type == :lvar && method_name != :initialize 'writer' end if kind add_offence(:convention, node.loc.keyword.line, sprintf(MSG, kind, kind)) end super end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.8.3 | lib/rubocop/cop/trivial_accessors.rb |
rubocop-0.8.2 | lib/rubocop/cop/trivial_accessors.rb |
rubocop-0.8.1 | lib/rubocop/cop/trivial_accessors.rb |