From b2e837f94d7efb894bbe43fafd68a725b10ee6d2 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Tue, 21 May 2024 23:30:27 +0100 Subject: [PATCH] rubocops/shared/desc_helper: fix autocorrect infinite loop --- Library/Homebrew/rubocops/shared/desc_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/rubocops/shared/desc_helper.rb b/Library/Homebrew/rubocops/shared/desc_helper.rb index 550bad0112..d19b4fc3e2 100644 --- a/Library/Homebrew/rubocops/shared/desc_helper.rb +++ b/Library/Homebrew/rubocops/shared/desc_helper.rb @@ -64,7 +64,7 @@ module RuboCop if type == :cask && (match = regex_match_group(desc, /\b(macOS|Mac( ?OS( ?X)?)?|OS ?X)(?! virtual machines?)\b/i)) && match[1] != "MAC" - desc_problem "Description shouldn't contain the platform." + add_offense(@offensive_source_range, message: "Description shouldn't contain the platform.") end # Check if a full stop is used at the end of a desc (apart from in the case of "etc."). @@ -109,6 +109,8 @@ module RuboCop correction.gsub!(/\s+$/, "") correction.gsub!(/\.$/, "") + next if correction == match_data[:correction] + corrector.replace(@offensive_node.source_range, "#{quote}#{correction}#{quote}") end end