formula_desc_cop: add unnecessary whitespace check

This commit is contained in:
Dominyk Tiller 2018-08-06 18:43:26 +01:00
parent 016ff24c97
commit 73194b460d
No known key found for this signature in database
GPG Key ID: FE19AEFCF658C6F6

View File

@ -38,6 +38,7 @@ module RuboCop
module FormulaAuditStrict
# This cop audits `desc` in Formulae
#
# - Checks for leading/trailing whitespace in `desc`
# - Checks if `desc` begins with an article
# - Checks for correct usage of `command-line` in `desc`
# - Checks description starts with a capital letter
@ -62,6 +63,16 @@ module RuboCop
desc = parameters(desc_call).first
# Check for leading whitespace.
if regex_match_group(desc, /^\s+/)
problem "Description shouldn't have a leading space"
end
# Check for trailing whitespace.
if regex_match_group(desc, /\s+$/)
problem "Description shouldn't have a trailing space"
end
# Check if command-line is wrongly used in formula's desc
if match = regex_match_group(desc, /(command ?line)/i)
c = match.to_s.chars.first
@ -104,6 +115,8 @@ module RuboCop
correction.gsub!(/^(['"]?)\s+/, "\\1")
correction.gsub!(/\s+(['"]?)$/, "\\1")
correction.gsub!(/\.(['"]?)$/, "\\1")
correction.gsub!(/^\s+/, "")
correction.gsub!(/\s+$/, "")
corrector.insert_before(node.source_range, correction)
corrector.remove(node.source_range)
end