Sha256: 652f029f84d7ee9dc524fe7cacf27131ef7c6c4bdae0cd9a79277f990fcdd213

Contents?: true

Size: 995 Bytes

Versions: 8

Compression:

Stored size: 995 Bytes

Contents

# encoding: utf-8
module RailsBestPractices
  module Reviews
    # Review all code to make sure we don't rescue Exception
    # This is a common mistake by Java or C# devs in ruby.
    #
    # See the best practice details here http://rails-bestpractices.com/posts/702-don-t-rescue-exception-rescue-standarderror
    #
    # Implementation:
    #
    # Review process:
    #   check all rescue node to see if its type is Exception
    class NotRescueExceptionReview < Review
      interesting_nodes :rescue
      interesting_files ALL_FILES
      url "http://rails-bestpractices.com/posts/702-don-t-rescue-exception-rescue-standarderror"

      # check rescue node to see if its type is Exception
      add_callback :start_rescue do |rescue_node|
        if rescue_node.exception_classes.any? { |rescue_class| "Exception" == rescue_class.to_s }
          add_error "not rescue Exception", rescue_node.file, rescue_node.exception_classes.first.line_number
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails_best_practices-1.15.4 lib/rails_best_practices/reviews/not_rescue_exception_review.rb
rails_best_practices-1.15.3 lib/rails_best_practices/reviews/not_rescue_exception_review.rb
rails_best_practices-1.15.2 lib/rails_best_practices/reviews/not_rescue_exception_review.rb
rails_best_practices-1.15.1 lib/rails_best_practices/reviews/not_rescue_exception_review.rb
rails_best_practices-1.14.4 lib/rails_best_practices/reviews/not_rescue_exception_review.rb
rails_best_practices-1.14.3 lib/rails_best_practices/reviews/not_rescue_exception_review.rb
rails_best_practices-1.14.2 lib/rails_best_practices/reviews/not_rescue_exception_review.rb
rails_best_practices-1.14.1 lib/rails_best_practices/reviews/not_rescue_exception_review.rb