class Rubocop::Cop::Style::TrivialAccessors
This cop looks for trivial reader/writer methods, that could have been created with the attr_* family of functions automatically.
Constants
- MSG
Public Instance Methods
on_def(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/trivial_accessors.rb, line 11 def on_def(node) method_name, args, body = *node kind = if body && body.type == :ivar 'reader' elsif args.children.size == 1 && body && body.type == :ivasgn && body.children[1] && body.children[1].type == :lvar && method_name != :initialize 'writer' end if kind add_offence(:convention, node.loc.keyword, sprintf(MSG, kind, kind)) end super end