Sha256: 04079490808028410cffde118e83417b2fb6f090a484876999ad47fc1b088428

Contents?: true

Size: 836 Bytes

Versions: 5

Compression:

Stored size: 836 Bytes

Contents

# encoding: utf-8

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 visibility_and_def_on_same_line?(receiver, method_name, args)
        !receiver &&
          [:public, :protected, :private,
           :module_function].include?(method_name) &&
          args.size == 1 && [:def, :defs].include?(args.first.type)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.30.1 lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.30.0 lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.29.1 lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.29.0 lib/rubocop/cop/mixin/on_method_def.rb
rubocop-0.28.0 lib/rubocop/cop/mixin/on_method_def.rb