Include binary op node to redundant return

This commit is contained in:
Vitalii Elenhaupt 2020-03-22 20:12:24 +02:00
parent 6a913be980
commit 946ec67fae
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
2 changed files with 25 additions and 0 deletions

View file

@ -104,6 +104,26 @@ module Ameba::Rule::Style
end
end
context "binary op" do
it "doesn't report if there is no return in the right binary op node" do
s = Source.new %(
def can_create?(a)
valid? && a > 0
end
)
subject.catch(s).should be_valid
end
it "reports if there is return in the right binary op node" do
s = Source.new %(
def can_create?(a)
valid? && return a > 0
end
)
subject.catch(s).should_not be_valid
end
end
context "case" do
it "reports if there are returns in whens" do
s = Source.new %(