Sha256: 8d7c46aa24a4fd649b708710781fd1f60ebe77763417a1f233413cac3826acd8

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    # Common functionality for checking instance methods and singeton methods.
    module CheckMethods
      def on_def(node)
        method_name, args, body = *node
        check(node, method_name, args, body)
      end

      def on_defs(node)
        _scope, method_name, args, body = *node
        check(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

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.22.0 lib/rubocop/cop/mixin/check_methods.rb
rubocop-0.21.0 lib/rubocop/cop/mixin/check_methods.rb