class RuboCop::Cop::Betterment::MemoizationWithArguments
Constants
- MSG
Private Class Methods
node_pattern()
click to toggle source
# File lib/rubocop/cop/betterment/memoization_with_arguments.rb, line 9 def self.node_pattern memo_assign = '(or_asgn $(ivasgn _) _)' memoized_at_end_of_method = "(begin ... #{memo_assign})" instance_method = "(def $_ _ {#{memo_assign} #{memoized_at_end_of_method}})" class_method = "(defs self $_ _ {#{memo_assign} #{memoized_at_end_of_method}})" "{#{instance_method} #{class_method}}" end
Public Instance Methods
on_def(node)
click to toggle source
# File lib/rubocop/cop/betterment/memoization_with_arguments.rb, line 22 def on_def(node) (method_name, ivar_assign) = memoized?(node) return if ivar_assign.nil? || node.arguments.length.zero? msg = format(MSG, method: method_name) add_offense(node, location: ivar_assign.source_range, message: msg) end
Also aliased as: on_defs