From f3d43110b5915bf06ee133c9d20f6a2df1a19ac6 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 3 Nov 2022 22:25:07 +0000 Subject: [PATCH 1/2] test/rubocops/formula_desc: Ensure that `desc` allows ending with `etc.` - This was funny (and embarrassing), I was looking at my first contributions to Homebrew since someone asked me how long I'd been involved. - Turns out that in 2017 I improved the formula description RuboCop rule to allow descriptions to end with `etc.` in https://github.com/Homebrew/brew/pull/3411. Apparently I didn't have time back then to write a test for it. So now I will remedy this 5 years later. --- Library/Homebrew/test/rubocops/formula_desc_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Library/Homebrew/test/rubocops/formula_desc_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_spec.rb index bef0ca1a18..0a8c81ce21 100644 --- a/Library/Homebrew/test/rubocops/formula_desc_spec.rb +++ b/Library/Homebrew/test/rubocops/formula_desc_spec.rb @@ -128,6 +128,15 @@ describe RuboCop::Cop::FormulaAudit::Desc do RUBY end + it "does not report an offense when the description ends with 'etc.'" do + expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/foo.rb") + class Foo < Formula + url 'https://brew.sh/foo-1.0.tgz' + desc 'Description of a thing and some more things and some more etc.' + end + RUBY + end + it "reports and corrects all rules for description text" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula From 6f2f97b98f1069fa299386fca31502e1101dbf13 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 3 Nov 2022 23:11:41 +0000 Subject: [PATCH 2/2] test/rubocops/formula_desc: Ensure autocorrect when `desc` ends in `.` - This was another thing that I should have done in PR 3411 in 2017, tested that the regex for autocorrecting `desc` stanzas ending in full stops actually worked. At least I'm getting to it now. --- Library/Homebrew/test/rubocops/formula_desc_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/rubocops/formula_desc_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_spec.rb index 0a8c81ce21..27280ab5da 100644 --- a/Library/Homebrew/test/rubocops/formula_desc_spec.rb +++ b/Library/Homebrew/test/rubocops/formula_desc_spec.rb @@ -118,12 +118,19 @@ describe RuboCop::Cop::FormulaAudit::Desc do RUBY end - it "reports an offense when the description ends with a full stop" do + it "report and corrects an offense when the description ends with a full stop" do expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb") class Foo < Formula url 'https://brew.sh/foo-1.0.tgz' desc 'Description with a full stop at the end.' - ^ Description shouldn\'t end with a full stop. + ^ Description shouldn't end with a full stop. + end + RUBY + + expect_correction(<<~RUBY) + class Foo < Formula + url 'https://brew.sh/foo-1.0.tgz' + desc 'Description with a full stop at the end' end RUBY end