<commit_before>module ConceptQL
  class SqlFormatter
    def format(sql)
      if command?('pg_formatter')
        sql, _ = Open3.capture2(formatter, stdin_data: sql)
        return sql
      end
      return sql
    rescue
      return sql
    end

    def command?(name)
      `which #{name}`
      $?.success?
    end
  end
end<commit_msg>SqlFormatter: fix a lot of confusing bugs<commit_after>module ConceptQL
  class SqlFormatter
    def format(sql)
      if command?(formatter)
        sql, _ = Open3.capture2(formatter, stdin_data: sql)
        return sql
      end
      return sql
    rescue
      return sql
    end

    def command?(name)
      `which #{name}`
      $?.success?
    end

    def formatter
      'pg_format'
    end
  end
end
{'fraction_non_alphanumeric': 0.07845744680851063, 'fraction_numerical': 0.005319148936170213, 'mean_word_length': 2.0860655737704916, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6588269', 'n_tokens_mistral': 236, 'n_tokens_neox': 233, 'n_words': 67}