class RubbyCop::Cop::Style::DocumentationMethod
This cop checks for missing documentation comment for public methods. It can optionally be configured to also require documentation for non-public methods.
@example
# bad class Foo def bar puts baz end end module Foo def bar puts baz end end def foo.bar puts baz end # good class Foo # Documentation def bar puts baz end end module Foo # Documentation def bar puts baz end end # Documentation def foo.bar puts baz end
Constants
- MSG
Public Instance Methods
on_def(node)
click to toggle source
# File lib/rubbycop/cop/style/documentation_method.rb, line 57 def on_def(node) check(node) end
on_method_def(node, *)
click to toggle source
# File lib/rubbycop/cop/style/documentation_method.rb, line 61 def on_method_def(node, *) check(node) end
Private Instance Methods
check(node)
click to toggle source
# File lib/rubbycop/cop/style/documentation_method.rb, line 67 def check(node) return if non_public?(node) && !require_for_non_public_methods? return if documentation_comment?(node) add_offense(node, :expression, MSG) end
require_for_non_public_methods?()
click to toggle source
# File lib/rubbycop/cop/style/documentation_method.rb, line 74 def require_for_non_public_methods? cop_config['RequireForNonPublicMethods'] end