<commit_before>module Danger
  # Lints files via Pronto through specified runners
  # Results are displayed as a table in markdown
  #
  # [Runners](https://github.com/mmozuras/pronto#runners)
  #
  # @example Lint files with Pronto and specified Pronto Runners
  #
  #          pronto.lint
  #
  # @see  RestlessThinker/danger-pronto
  # @tags pronto, linter
  #
  class DangerPronto < Plugin

    # Runs files through Pronto. Generates a `markdown` list of warnings.
    #
    # @param [String] files
    #         A globbed string which should return the files that you want to
    #         run though, defaults to nil. If nil, modified and added files from
    #         the diff will be used.
    # @return [void]
    #
    def lint(files = nil)
      files_to_lint = fetch_files_to_lint(files)

      return if offending_files.empty?

      markdown offenses_message(offending_files)
    end

    def offending_files(files = nil)
      files_to_lint = fetch_files_to_lint(files)
      pronto(files_to_lint)
    end

    private

    # Executes pronto command
    #
    # @param [Array<String>] Files to lint
    # @return [Hash] Converted hash from pronto json output
    #
    def pronto(files_to_lint)
      pronto_output = `#{'bundle exec ' if File.exists?('Gemfile')}pronto run -f json`

      JSON.parse(pronto_output)
          .select { |f| files_to_lint.include?(f['path']) }
    end

    # Builds the t<commit_msg>add logging to see pronto output<commit_after>module Danger
  # Lints files via Pronto through specified runners
  # Results are displayed as a table in markdown
  #
  # [Runners](https://github.com/mmozuras/pronto#runners)
  #
  # @example Lint files with Pronto and specified Pronto Runners
  #
  #          pronto.lint
  #
  # @see  RestlessThinker/danger-pronto
  # @tags pronto, linter
  #
  class DangerPronto < Plugin

    # Runs files through Pronto. Generates a `markdown` list of warnings.
    #
    # @param [String] files
    #         A globbed string which should return the files that you want to
    #         run though, defaults to nil. If nil, modified and added files from
    #         the diff will be used.
    # @return [void]
    #
    def lint(files = nil)
      files_to_lint = fetch_files_to_lint(files)

      return if offending_files.empty?

      markdown offenses_message(offending_files)
    end

    def offending_files(files = nil)
      files_to_lint = fetch_files_to_lint(files)
      pronto(files_to_lint)
    end

    private

    # Executes pronto command
    #
    # @param [Array<String>] Files to lint
    # @return [Hash] Converted hash from pronto json output
    #
    def pronto(files_to_lint)
      pronto_output = `#{'bundle exec ' if File.exists?('Gemfile')}pronto run -f json`

      puts pronto_output.inspect

      JSON.parse(pronto_output)
          .select { |f| files_to_lint.include?(f['path']) }
    end

    # Builds the t
{'fraction_non_alphanumeric': 0.08341915550978372, 'fraction_numerical': 0.0, 'mean_word_length': 2.6700251889168767, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '745580', 'n_tokens_mistral': 966, 'n_tokens_neox': 913, 'n_words': 272}