mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Add Lint/MissingBlockArgument
rule
This commit is contained in:
parent
e6ebca7a5b
commit
597372c645
2 changed files with 91 additions and 0 deletions
42
spec/ameba/rule/lint/missing_block_argument_spec.cr
Normal file
42
spec/ameba/rule/lint/missing_block_argument_spec.cr
Normal file
|
@ -0,0 +1,42 @@
|
|||
require "../../../spec_helper"
|
||||
|
||||
module Ameba::Rule::Lint
|
||||
subject = MissingBlockArgument.new
|
||||
|
||||
describe MissingBlockArgument do
|
||||
it "passes if the block argument is defined" do
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
def foo(&)
|
||||
yield 42
|
||||
end
|
||||
|
||||
def bar(&block)
|
||||
yield 24
|
||||
end
|
||||
|
||||
def baz(a, b, c, &block)
|
||||
yield a, b, c
|
||||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports if the block argument is missing" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
def foo
|
||||
# ^^^ error: Missing anonymous block argument. Use `&` as an argument name to indicate yielding method.
|
||||
yield 42
|
||||
end
|
||||
|
||||
def bar
|
||||
# ^^^ error: Missing anonymous block argument. Use `&` as an argument name to indicate yielding method.
|
||||
yield 24
|
||||
end
|
||||
|
||||
def baz(a, b, c)
|
||||
# ^^^ error: Missing anonymous block argument. Use `&` as an argument name to indicate yielding method.
|
||||
yield a, b, c
|
||||
end
|
||||
CRYSTAL
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue