diff --git a/Library/Homebrew/rubocops/patches.rb b/Library/Homebrew/rubocops/patches.rb index 5a0e0effae..13cffc6dca 100644 --- a/Library/Homebrew/rubocops/patches.rb +++ b/Library/Homebrew/rubocops/patches.rb @@ -18,7 +18,7 @@ module RuboCop patch_problems(url_string) end - inline_patches = find_method_calls_by_name(body, :patch) + inline_patches = find_every_method_call_by_name(body, :patch) inline_patches.each { |patch| inline_patch_problems(patch) } if inline_patches.empty? && patch_end? diff --git a/Library/Homebrew/test/rubocops/patches_spec.rb b/Library/Homebrew/test/rubocops/patches_spec.rb index 6b0fc2a1a5..42883c8458 100644 --- a/Library/Homebrew/test/rubocops/patches_spec.rb +++ b/Library/Homebrew/test/rubocops/patches_spec.rb @@ -175,6 +175,19 @@ describe RuboCop::Cop::FormulaAudit::Patches do RUBY end + it "reports no offenses for valid nested inline patches" do + expect_no_offenses(<<~RUBY) + class Foo < Formula + url 'https://brew.sh/foo-1.0.tgz' + stable do + patch :DATA + end + end + __END__ + patch content here + RUBY + end + it "reports an offense when DATA is found with no __END__" do expect_offense(<<~RUBY) class Foo < Formula