Class: RuboCop::Cop::Style::PublicMethodDocumentation
- Inherits:
-
DocumentationMethod
- Object
- DocumentationMethod
- RuboCop::Cop::Style::PublicMethodDocumentation
- Includes:
- DefNode, DocumentationComment
- Defined in:
- lib/rubocop/cop/style/public_method_documentation.rb
Overview
TODO: Write cop description and example of bad / good code. For every ‘SupportedStyle` and unique configuration, there needs to be examples. Examples must have valid Ruby syntax. Do not use upticks.
Constant Summary collapse
- ATTRS_DOC =
'# === Attributes:'
- RETURNS_DOC =
'# === Returns:'
- PARMS_DOC =
'# === Parameters:'
- MSG_ATTRIBUTES_AND_PARAMETERS_NO_COEXIST =
'Attributes and Parameters should not exist on same method.'
- MSG_DESCRIPTION_SHOULD_END_WITH_BLANK_COMMENT =
'Description should end with blank comment.'
- MSG_ILLEGAL_RANGE_BODY_FORMAT =
"Illegal %s format: '# * <tt>:{argument}</tt> {description}'."
- MSG_ILLEGAL_RANGE_RET_BODY_FORMAT =
"Illegal %s format: '# * <tt>{CLASS}</tt> {description}'."
- MSG_INVALID_DOCUMENTATION =
'Invalid public method documentation comment for `%s`.'
- MSG_MISSING_DOCUMENTATION =
'Missing public method documentation comment for `%s`.'
- MSG_MISSING_PARAMETERS =
'Parameter is missing for `%s`.'
- MSG_PARAMETERS_ARG_NAME_MISMATCH =
'Parameter name `%s` does not match argument name `%s`.'
- MSG_PARAMETERS_ARG_SIZE_MISMATCH =
'Parameter size `%s` does not match argument size `%s`.'
- MSG_PARAMETERS_SHOULD_BE_BEFORE_RETURNS =
'Parameters should be before Returns.'
- MSG_RANGE_BODY_EMPTY =
'%s body is empty.'
- MSG_RETURNS_SHOULD_BE_LAST =
'Returns should be last.'
- MSG_UNNECESSARY_PARAMETERS =
'Unnecessary Parameter documentation for `%s`.'
- ATTR_REGEXP =
/^ *# *=== *Attributes:/.freeze
- DOC_PARM_REGEXP =
%r{^# \* <tt>:(\w+)</tt>}.freeze
- DOC_RET_REGEXP =
%r{^# \* <tt>([:\w]+)</tt>}.freeze
- DOC_SUB_PARM_REGEXP =
%r{^# \** <code>([.:\w ]+-*[.:\w ]+)</code>([.:\w ]*-*[.:\w ]*)}.freeze
- PARMS_REGEXP =
/^ *# *=== *Parameters:/.freeze
- RETURNS_REGEXP =
/^ *# *=== *Returns: */.freeze
Instance Method Summary collapse
-
#on_def(node) ⇒ Object
checks for public methods to make sure they have proper documentation if not it will add an offense.
Instance Method Details
#on_def(node) ⇒ Object
checks for public methods to make sure they have proper documentation
if not it will add an offense
Parameters:
-
:node
a def node
78 79 80 81 82 |
# File 'lib/rubocop/cop/style/public_method_documentation.rb', line 78 def on_def(node) # puts("start-#{node.children.first.to_s}") check(node) # puts 'end-on_def' end |