Class: RuboCop::Cop::Yardoc::ParamDescriptionCasing
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/yardoc/param_description_casing.rb
Overview
Ensure every "param" and "return" tag starts with an uppercased letter
It ignores description starting with non latin characters
Defined Under Namespace
Classes: CommentEntry
Constant Summary collapse
- MSG =
'First letter of a @param or @return tag should be in uppercase'- PARAM_REGEXP =
Matches a "param" tag line
/(?<definition>\A#\s+@param\s+[^\[]+(?:\s+\[[^\]]+\])?\s+)(?<desc>[a-z].*)/- RETURN_REGEXP =
Matches a "return" tag line
/(?<definition>\A#\s+@return\s+(?:\[[^\]]+\])?\s+)(?<desc>[a-z].*)/
Instance Method Summary collapse
-
#on_def(node) ⇒ Object
(also: #on_defs)
Executed for each method definition.
Instance Method Details
#on_def(node) ⇒ Object Also known as: on_defs
Executed for each method definition
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubocop/cop/yardoc/param_description_casing.rb', line 46 def on_def(node) return unless documented? node processed_source.comments .each do |line| match = line.text.match(PARAM_REGEXP) || line.text.match(RETURN_REGEXP) next unless match range = offense_range(line, match[:definition]) add_offense(range) do |corrector| corrector.replace(range, match[:desc][0].upcase) end end end |