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
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
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubocop/cop/yardoc/param_description_casing.rb', line 34 def on_def(node) return unless documented? node node_comments(node).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 |