<commit_before>module Danger


  class DangerClorox < Plugin

    # Checks presence of file header comments. Will fail if `clorox` cannot be installed correctly.
    # Generates a `markdown` list of dirty Objective-C and Swift files
    #
    # @param   [String] files
    #          A globbed string which should return the files that you want to check, defaults to nil.
    #          if nil, modified and added files from the diff will be used.
    # @return  [void]
    #
    def check_files(files=nil)
      # Installs clorox if needed
      system "pip install --target /tmp/danger_clorox clorox" unless clorox_installed?

      # Check that this is in the user's PATH after installing
      unless clorox_installed?
        fail "clorox is not in the user's PATH, or it failed to install"
        return
      end

      # Either use files provided, or use the modified + added
      files = files ? Dir.glob(files) : (modified_files + added_files).uniq

      require 'json'
      result = JSON.parse(`python /tmp/danger_clorox/clorox/clorox.py -p #{files.join(" ")} -i -r json`)

      message = ''
      if result['status'] == 'dirty'
        message = "### Clorox has found issues\n"
        message << "Please, remove the header from the files below (those comments on the top of your file):\n\n"
        message << parse_results(result['files'])
        markdown message
      end
    end

    # Parses clorox invocation results into a string
    # which is formatted as a markdown table.
    #
    # @return  [String]
    #
    def parse_results(results)
      message = ""
      results.each do |r|
        message << "- #{r} :hankey:\n"
      end

      message
    end

    # Determine if clorox is currently installed in the system paths.
    # @return  [Bool]
    #
    def clorox_installed?<commit_msg>lib: fix call to 'modified_files' and 'added_files'<commit_after>module Danger


  class DangerClorox < Plugin

    # Checks presence of file header comments. Will fail if `clorox` cannot be installed correctly.
    # Generates a `markdown` list of dirty Objective-C and Swift files
    #
    # @param   [String] files
    #          A globbed string which should return the files that you want to check, defaults to nil.
    #          if nil, modified and added files from the diff will be used.
    # @return  [void]
    #
    def check_files(files=nil)
      # Installs clorox if needed
      system "pip install --target /tmp/danger_clorox clorox" unless clorox_installed?

      # Check that this is in the user's PATH after installing
      unless clorox_installed?
        fail "clorox is not in the user's PATH, or it failed to install"
        return
      end

      # Either use files provided, or use the modified + added
      files = files ? Dir.glob(files) : (git.modified_files + git.added_files).uniq

      require 'json'
      result = JSON.parse(`python /tmp/danger_clorox/clorox/clorox.py -p #{files.join(" ")} -i -r json`)

      message = ''
      if result['status'] == 'dirty'
        message = "### Clorox has found issues\n"
        message << "Please, remove the header from the files below (those comments on the top of your file):\n\n"
        message << parse_results(result['files'])
        markdown message
      end
    end

    # Parses clorox invocation results into a string
    # which is formatted as a markdown table.
    #
    # @return  [String]
    #
    def parse_results(results)
      message = ""
      results.each do |r|
        message << "- #{r} :hankey:\n"
      end

      message
    end

    # Determine if clorox is currently installed in the system paths.
    # @return  [Bool]
    #
    def clorox_installed?
{'fraction_non_alphanumeric': 0.08644986449864499, 'fraction_numerical': 0.0, 'mean_word_length': 2.40184331797235, 'pattern_counts': {'":': 0, '<': 17, '<?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': '3907742', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1051, 'n_words': 409}