From 0786d41693e1ff298d799d055a342dccaaea3fe6 Mon Sep 17 00:00:00 2001 From: Isabell Long Date: Wed, 1 Nov 2017 19:10:48 +0000 Subject: formula_desc_cop: If desc ends with 'etc.', it's not a violation --- Library/Homebrew/rubocops/formula_desc_cop.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/rubocops/formula_desc_cop.rb b/Library/Homebrew/rubocops/formula_desc_cop.rb index 69fbeb56e..6aa395ee7 100644 --- a/Library/Homebrew/rubocops/formula_desc_cop.rb +++ b/Library/Homebrew/rubocops/formula_desc_cop.rb @@ -40,7 +40,7 @@ module RuboCop # - Checks for correct usage of `command-line` in `desc` # - Checks description starts with a capital letter # - Checks if `desc` contains the formula name - # - Checks if `desc` ends with a full stop + # - Checks if `desc` ends with a full stop (apart from in the case of "etc.") class Desc < FormulaCop VALID_LOWERCASE_WORDS = %w[ ex @@ -83,8 +83,8 @@ module RuboCop problem "Description shouldn't start with the formula name" end - # Check if a full stop is used at the end of a formula's desc - return unless regex_match_group(desc, /\.$/) + # Check if a full stop is used at the end of a formula's desc (apart from in the case of "etc.") + return unless regex_match_group(desc, /\.$/) && !string_content(desc).end_with?("etc.") problem "Description shouldn't end with a full stop" end -- cgit v1.2.3 From 5cbb41479731a5ea95fc9ec9a44b39b72df51995 Mon Sep 17 00:00:00 2001 From: Isabell Long Date: Wed, 1 Nov 2017 19:17:17 +0000 Subject: formula_desc_cop: Fix the 'full stop at end of description' autocorrect - It wasn't working because desc strings end in quotes, not just full stops. --- Library/Homebrew/rubocops/formula_desc_cop.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/rubocops/formula_desc_cop.rb b/Library/Homebrew/rubocops/formula_desc_cop.rb index 6aa395ee7..8a35e7d24 100644 --- a/Library/Homebrew/rubocops/formula_desc_cop.rb +++ b/Library/Homebrew/rubocops/formula_desc_cop.rb @@ -103,7 +103,7 @@ module RuboCop correction.gsub!(/(^|[^a-z])#{@formula_name}([^a-z]|$)/i, "\\1\\2") correction.gsub!(/^(['"]?)\s+/, "\\1") correction.gsub!(/\s+(['"]?)$/, "\\1") - correction.gsub!(/\.$/, "") + correction.gsub!(/\.(['"]?)$/, "\\1") corrector.insert_before(node.source_range, correction) corrector.remove(node.source_range) end -- cgit v1.2.3