<commit_before>Rake::TaskManager.record_task_metadata = true

module Bugsnag::Rake
  def self.included(base)
    base.extend ClassMethods
    base.class_eval do
      class << self
        alias_method :original_define_task, :define_task
        alias_method :define_task, :bugsnag_define_task
      end
    end
  end

  module ClassMethods
    def bugsnag_define_task(*args, &block)
      task = self.original_define_task *args do
        begin
          Bugsnag.before_notify_callbacks << lambda {|notif|
            notif.add_tab(:rake_task, {
              :name => task.name,
              :description => task.full_comment,
              :arguments => task.arg_description
            })
            notif.context ||= task.name
          }

          yield
        rescue Exception => e
          Bugsnag.notify(e)
          raise
        end
      end
    end
  end
end

Rake::Task.send(:include, Bugsnag::Rake) if defined?(Rake::Task)<commit_msg>need to be able to cope with tasks that have no block<commit_after>Rake::TaskManager.record_task_metadata = true

module Bugsnag::Rake
  def self.included(base)
    base.extend ClassMethods
    base.class_eval do
      class << self
        alias_method :original_define_task, :define_task
        alias_method :define_task, :bugsnag_define_task
      end
    end
  end

  module ClassMethods
    def bugsnag_define_task(*args, &block)
      task = self.original_define_task *args do
        begin
          Bugsnag.before_notify_callbacks << lambda {|notif|
            notif.add_tab(:rake_task, {
              :name => task.name,
              :description => task.full_comment,
              :arguments => task.arg_description
            })
            notif.context ||= task.name
          }

          yield if block_given?
        rescue Exception => e
          Bugsnag.notify(e)
          raise
        end
      end
    end
  end
end

Rake::Task.send(:include, Bugsnag::Rake) if defined?(Rake::Task)
{'fraction_non_alphanumeric': 0.0840122199592668, 'fraction_numerical': 0.0, 'mean_word_length': 2.128980891719745, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6917031', 'n_tokens_mistral': 588, 'n_tokens_neox': 583, 'n_words': 128}