<commit_before>require 'rubygems'
begin
  if RUBY_VERSION =~ /^1\.9/
    #Load our own version of ruby_parser :'(
    require 'ruby_parser/ruby_parser.rb'
  else
    require 'ruby_parser'
    require 'ruby_parser/bm_sexp.rb'
  end

  require 'haml'
  require 'sass'
  require 'erb'
  require 'erubis'
  require 'brakeman/processor'
  require 'brakeman/parsers/rails2_erubis'
  require 'brakeman/parsers/rails2_xss_plugin_erubis'
  require 'brakeman/parsers/rails3_erubis'
rescue LoadError => e
  $stderr.puts e.message
  $stderr.puts "Please install the appropriate dependency."
  exit
end

#Scans the Rails application.
class Brakeman::Scanner
  attr_reader :options

  RUBY_1_9 = !!(RUBY_VERSION =~ /^1\.9/)

  #Pass in path to the root of the Rails application
  def initialize options, processor = nil
    @options = options
    @report_progress = options[:report_progress]
    @path = options[:app_path]
    @app_path = File.join(@path, "app")
    @processor = processor || Brakeman::Processor.new(options)
    @skip_files = nil

    #Convert files into Regexp for matching
    if options[:skip_files]
      list = "(?:" << options[:skip_files].map { |f| Regexp.escape f }.join("|") << ")$"
      @skip_files = Regexp.new(list)
    end

    if RUBY_1_9
      @ruby_parser = ::Ruby19Parser
    else
      @ruby_parser = ::RubyParser
    end
  end

  #Returns the Tracker generated from the scan
  def tracker
    @processor.tracked_events
  end

  #Process everything in the Rails application
  def process
    Brakeman.notify "Processing configuration..."
    process_config
    Brakeman.notify "Processing gems..."
    process_gems
    Brakeman.notify "Processing initializers..."
    process_initializers
    Brakeman.notify "Processing libs..."
    process_libs
    Brakeman.notify "Processing routes...        "
    process_routes
    Brakeman.notify "Processing templates...     "
    process_templates
    Brakeman.notify "Processing models...        "
    process_models
    Brakeman.notify "Processing controllers...   "
    process_controllers
    Brakeman.notify "Indexing call sites...      "<commit_msg>A little more whitespace when showing progress<commit_after>require 'rubygems'
begin
  if RUBY_VERSION =~ /^1\.9/
    #Load our own version of ruby_parser :'(
    require 'ruby_parser/ruby_parser.rb'
  else
    require 'ruby_parser'
    require 'ruby_parser/bm_sexp.rb'
  end

  require 'haml'
  require 'sass'
  require 'erb'
  require 'erubis'
  require 'brakeman/processor'
  require 'brakeman/parsers/rails2_erubis'
  require 'brakeman/parsers/rails2_xss_plugin_erubis'
  require 'brakeman/parsers/rails3_erubis'
rescue LoadError => e
  $stderr.puts e.message
  $stderr.puts "Please install the appropriate dependency."
  exit
end

#Scans the Rails application.
class Brakeman::Scanner
  attr_reader :options

  RUBY_1_9 = !!(RUBY_VERSION =~ /^1\.9/)

  #Pass in path to the root of the Rails application
  def initialize options, processor = nil
    @options = options
    @report_progress = options[:report_progress]
    @path = options[:app_path]
    @app_path = File.join(@path, "app")
    @processor = processor || Brakeman::Processor.new(options)
    @skip_files = nil

    #Convert files into Regexp for matching
    if options[:skip_files]
      list = "(?:" << options[:skip_files].map { |f| Regexp.escape f }.join("|") << ")$"
      @skip_files = Regexp.new(list)
    end

    if RUBY_1_9
      @ruby_parser = ::Ruby19Parser
    else
      @ruby_parser = ::RubyParser
    end
  end

  #Returns the Tracker generated from the scan
  def tracker
    @processor.tracked_events
  end

  #Process everything in the Rails application
  def process
    Brakeman.notify "Processing configuration..."
    process_config
    Brakeman.notify "Processing gems..."
    process_gems
    Brakeman.notify "Processing initializers..."
    process_initializers
    Brakeman.notify "Processing libs..."
    process_libs
    Brakeman.notify "Processing routes...          "
    process_routes
    Brakeman.notify "Processing templates...       "
    process_templates
    Brakeman.notify "Processing models...          "
    process_models
    Brakeman.notify "Processing controllers...     "
    process_controllers
    Brakeman.notify "Indexing call sites...        "
{'fraction_non_alphanumeric': 0.10039691804809713, 'fraction_numerical': 0.006070511323838431, 'mean_word_length': 3.1795121951219514, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '6503718', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1345, 'n_words': 346}