formula_desc_cop: empty string is not a valid desc

Just a slightly tweaked version of https://github.com/Homebrew/brew/issues/3286#issuecomment-334983011
This commit is contained in:
Dominyk Tiller 2017-10-09 17:01:35 +01:00
parent e1808bf0e3
commit 075f818118
No known key found for this signature in database
GPG Key ID: FE19AEFCF658C6F6

View File

@ -18,8 +18,14 @@ module RuboCop
return
end
# Check if a formula's desc is too long
# Check the formula's desc length. Should be >0 and <80 characters.
desc = parameters(desc_call).first
pure_desc_length = string_content(desc).length
if pure_desc_length.zero?
problem "The desc (description) should not be an empty string."
return
end
desc_length = "#{@formula_name}: #{string_content(desc)}".length
max_desc_length = 80
return if desc_length <= max_desc_length