Skip to content
Snippets Groups Projects
Unverified Commit 5b090a7d authored by Markus Reiter's avatar Markus Reiter Committed by GitHub
Browse files

Merge pull request #8356 from reitermarkus/desc-length

Don't take name into account when calculating description length.
parents 6803bf54 750e299d
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@ module RuboCop
module DescHelper
include HelperFunctions
MAX_DESC_LENGTH = 80
VALID_LOWERCASE_WORDS = %w[
iOS
iPhone
......@@ -27,8 +29,8 @@ module RuboCop
desc = desc_call.first_argument
# Check if the desc is empty.
pure_desc_length = string_content(desc).length
if pure_desc_length.zero?
desc_length = string_content(desc).length
if desc_length.zero?
problem "The desc (description) should not be an empty string."
return
end
......@@ -64,13 +66,11 @@ module RuboCop
problem "Description shouldn't end with a full stop."
end
# Check if the desc length exceeds 80 characters.
desc_length = "#{name}: #{string_content(desc)}".length
max_desc_length = 80
return if desc_length <= max_desc_length
# Check if the desc length exceeds maximum length.
return if desc_length <= MAX_DESC_LENGTH
problem "Description is too long. \"name: desc\" should be less than #{max_desc_length} characters. " \
"The current combined length is #{desc_length}."
problem "Description is too long. It should be less than #{MAX_DESC_LENGTH} characters. " \
"The current length is #{desc_length}."
end
def autocorrect_desc(node, name)
......
......@@ -30,7 +30,7 @@ describe RuboCop::Cop::FormulaAudit::Desc do
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
desc 'Bar#{"bar" * 29}'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description is too long. "name: desc" should be less than 80 characters. The current combined length is 95.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description is too long. It should be less than 80 characters. The current length is 90.
end
RUBY
end
......@@ -41,7 +41,7 @@ describe RuboCop::Cop::FormulaAudit::Desc do
url 'https://brew.sh/foo-1.0.tgz'
desc 'Bar#{"bar" * 9}'\
'#{"foo" * 21}'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description is too long. "name: desc" should be less than 80 characters. The current combined length is 98.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description is too long. It should be less than 80 characters. The current length is 93.
end
RUBY
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment