<commit_before>module QueryReviewer
  module MysqlAnalyzer
    def do_mysql_analysis!
      analyze_select_type!
      analyze_query_type!
      analyze_key!
      analyze_extras!
      analyze_keylen!
    end

    def analyze_select_type!
      if select_type.match /uncacheable subquery/
        warn(:severity => 10, :field => "select_type", :desc => "Subquery must be run once for EVERY row in main query")
      elsif select_type.match /dependent/
        warn(:severity => 2, :field => "select_type", :desc => "Dependent subqueries can not be executed while the main query is running")
      end
    end

    def analyze_query_type!
      case query_type
      when "system", "const", "eq_ref":
        praise("Yay")
      when "ref", "ref_or_null", "range", "index_merge":
        praise("Not bad eh...")
      when "unique_subquery", "index_subquery":
        #NOT SURE
      when "index":
        warn(:severity => 8, :field => "query_type", :desc => "Full index tree scan (slightly faster than a full table scan)") unless !extra.include?("using where")
      when "all":<commit_msg>Fixes for deprecation and ruby 1.9 compatability<commit_after>module QueryReviewer
  module MysqlAnalyzer
    def do_mysql_analysis!
      analyze_select_type!
      analyze_query_type!
      analyze_key!
      analyze_extras!
      analyze_keylen!
    end

    def analyze_select_type!
      if select_type.match /uncacheable subquery/
        warn(:severity => 10, :field => "select_type", :desc => "Subquery must be run once for EVERY row in main query")
      elsif select_type.match /dependent/
        warn(:severity => 2, :field => "select_type", :desc => "Dependent subqueries can not be executed while the main query is running")
      end
    end

    def analyze_query_type!
      case query_type
      when "system", "const", "eq_ref" then
        praise("Yay")
      when "ref", "ref_or_null", "range", "index_merge" then
        praise("Not bad eh...")
      when "unique_subquery", "index_subquery" then
        #NOT SURE
      when "index" then
        warn(:severity => 8, :field => "query_type", :desc => "Full index tree scan (slightly faster than a full table scan)") unless !extra.include?("using where")
      when "all" then
{'fraction_non_alphanumeric': 0.10719071013845467, 'fraction_numerical': 0.0044662795891022775, 'mean_word_length': 2.9786856127886323, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 21, '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': '2347722', 'n_tokens_mistral': 696, 'n_tokens_neox': 680, 'n_words': 212}