Sha256: 3c4ff43c01edc619c123a0d4b104dbe45aa06a639bd37c5534ca7604b3b52924

Contents?: true

Size: 833 Bytes

Versions: 11

Compression:

Stored size: 833 Bytes

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

      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.nil? &&
          send_node.method_name != :def &&
          send_node.method_args.size == 1 &&
          [:def, :defs].include?(send_node.method_args.first.type)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/mixin/on_method_def.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/cop/mixin/on_method_def.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/mixin/on_method_def.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/mixin/on_method_def.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/mixin/on_method_def.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/mixin/on_method_def.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.46.0 lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.45.0 lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.44.1 lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.44.0 lib/rubocop/cop/mixin/on_method_def.rb