class RuboCop::Cop::Style::DocumentationMethod
end
end
def respond_to_missing?(symbol, include_private)
end
def method_missing(name, *args)
class Foo
# good
@example AllowedMethods: [‘method_missing’, ‘respond_to_missing?’]
end
end
def do_something
# Documentation
private
class Foo
end
end
def do_something
# Documentation
protected
class Foo
# good
end
end
def do_something
private
class Foo
end
end
def do_something
protected
class Foo
# bad
@example RequireForNonPublicMethods: true
end
end
def do_something
private
class Foo
end
end
def do_something
protected
class Foo
# good
@example RequireForNonPublicMethods: false (default)
end
puts baz
def foo.bar
# Documentation
end
end
puts baz
def bar
# Documentation
module Foo
end
end
puts baz
def bar
# Documentation
class Foo
# good
end
puts baz
def foo.bar
end
end
puts baz
def bar
module Foo
end
end
puts baz
def bar
class Foo
# bad
@example
they are called constructor to distinguish it from method.
a special method called from ‘new`. In some programming languages
NOTE: This cop allows `initialize` method because `initialize` is
non-public methods.
It can optionally be configured to also require documentation for
Checks for missing documentation comment for public methods.
def allowed_methods
def allowed_methods @allowed_methods ||= cop_config.fetch('AllowedMethods', []).map(&:to_sym) end
def check(node)
def check(node) return if non_public?(node) && !require_for_non_public_methods? return if documentation_comment?(node) return if method_allowed?(node) add_offense(node) end
def method_allowed?(node)
def method_allowed?(node) allowed_methods.include?(node.method_name) end
def on_def(node)
def on_def(node) return if node.method?(:initialize) parent = node.parent modifier_node?(parent) ? check(parent) : check(node) end
def require_for_non_public_methods?
def require_for_non_public_methods? cop_config['RequireForNonPublicMethods'] end