Sha256: 0981d160b83d827ad9af0d34ab2132d8be77a309d6ce811fec9ab89e0b898c7b
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module RuboCop module Cop # Common functionality for checking instance methods and singleton methods. module OnMethodDef def on_def(node) method_name, args, body = *node on_method_def(node, method_name, args, body) end def on_defs(node) _scope, method_name, args, body = *node on_method_def(node, method_name, args, body) end # This method provides scope agnostic method node destructuring by moving # the scope to the end where it can easily be ignored. def method_def_node_parts(node) if node.def_type? method_name, args, body = *node elsif node.defs_type? scope, method_name, args, body = *node else return [] end [method_name, args, body, scope] end private # Returns true for constructs such as # private def my_method # which are allowed in Ruby 2.1 and later. def modifier_and_def_on_same_line?(send_node) !send_node.receiver && send_node.method_name != :def && send_node.arguments.one? && %i[def defs].include?(send_node.first_argument.type) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.49.1 | lib/rubocop/cop/mixin/on_method_def.rb |
rubocop-0.49.0 | lib/rubocop/cop/mixin/on_method_def.rb |
rubocop-0.48.1 | lib/rubocop/cop/mixin/on_method_def.rb |