Find patch nodes nested inside blocks
This commit is contained in:
parent
b2eafdf11d
commit
ffb1cc8e19
@ -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?
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user