<commit_before># encoding: utf-8
require 'rails_best_practices/reviews/review'

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://stackoverflow.com/questions/10048173/why-is-it-bad-style-to-rescue-exception-e-in-ruby
    #
    # 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://stackoverflow.com/questions/10048173/why-is-it-bad-style-to-rescue-exception-e-in-ruby"

      # check rescue node to see if its type is Exception
      add_callback :start_rescue do |node|
        rescue_args = node[1]
        if rescue_args
          rescue_type = rescue_args.first
          if rescue_type && rescue_type.first == :var_ref
            rescue_type_var = rescue_type[1]
            if rescue_type_var.first == :@const
              if "Exception" == rescue_type_var[1]
                # 'rescue' nodes do not have line-number info, but the rescue_type
                # node does.<commit_msg>change url for NotRescueExceptionReview<commit_after># encoding: utf-8
require 'rails_best_practices/reviews/review'

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 |node|
        rescue_args = node[1]
        if rescue_args
          rescue_type = rescue_args.first
          if rescue_type && rescue_type.first == :var_ref
            rescue_type_var = rescue_type[1]
            if rescue_type_var.first == :@const
              if "Exception" == rescue_type_var[1]
                # 'rescue' nodes do not have line-number info, but the rescue_type
                # node does.
{'fraction_non_alphanumeric': 0.07556270096463022, 'fraction_numerical': 0.012057877813504822, 'mean_word_length': 2.6072463768115943, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6888370', 'n_tokens_mistral': 756, 'n_tokens_neox': 720, 'n_words': 212}