Skip to content
Browse files

support nil as a valid response for an empty rescue block.

  • Loading branch information...
1 parent 5a63521 commit cb7a0f43ed56be50bcf41e43177e93ece8bd092e @martinjandrews martinjandrews committed May 4, 2009
View
2 lib/roodi/checks/empty_rescue_body_check.rb
@@ -7,7 +7,7 @@ module Checks
# When the body of a rescue block is empty, exceptions can get caught and swallowed without
# any feedback to the user.
class EmptyRescueBodyCheck < Check
- STATEMENT_NODES = [:fcall, :return, :attrasgn, :vcall]
+ STATEMENT_NODES = [:fcall, :return, :attrasgn, :vcall, :nil]
def interesting_nodes
[:resbody]
View
9 spec/roodi/checks/empty_rescue_body_check_spec.rb
@@ -90,6 +90,15 @@
errors[0].to_s.should eql("dummy-file.rb:3 - Rescue block should not be empty.")
end
+ it "should accept a rescue block with an explicit nil" do
+ content = <<-END
+ call_method rescue nil
+ END
+ @roodi.check_content(content)
+ errors = @roodi.errors
+ errors.should be_empty
+ end
+
it "should reject an empty rescue block with a parameter" do
content = <<-END
begin

0 comments on commit cb7a0f4

Please sign in to comment.
Something went wrong with that request. Please try again.