Sha256: d13b1e73e900a9f339a9e7179146dde6d454bce40c5334b0eafe2f70491fcd4a

Contents?: true

Size: 824 Bytes

Versions: 5

Compression:

Stored size: 824 Bytes

Contents

# encoding: utf-8

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

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

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/mixin/on_method.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/mixin/on_method.rb
rubocop-0.26.1 lib/rubocop/cop/mixin/on_method.rb
rubocop-0.26.0 lib/rubocop/cop/mixin/on_method.rb
rubocop-0.25.0 lib/rubocop/cop/mixin/on_method.rb