<commit_before>module Fastlane
  module Actions
    class EnsureNoDebugCodeAction < Action
      def self.run(params)
        results = sh "grep -R '#{params[:text]}' '#{params[:path]}'"
        return results if Helper.is_test?
        
        # Example Output
        #   ./fastlane.gemspec:  spec.add_development_dependency 'pry'
        #   ./Gemfile.lock:    pry (0.10.1)

        found = []
        results.split("\n").each do |current_raw|
          current = current_raw.strip
          if params[:extension]
            if current.include?".#{params[:extension]}:"
              found << current
            end
          else
            found << current
          end
        end

        raise "Found debug code '#{params[:text]}': \n\n#{found.join("\n")}" if found.count > 0
        Helper.log.info "No debug code found in code base 🐛"
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "Ensures the given text is nowhere in the code base"
      end

      def self.details
        [
          "Makes sure the given text is nowhere in the code base. This can be used",
          "to check if there is any debug code still in your code base or if you have",
          "things like // TODO or similar"
        ].join(" ")
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :text,
                                       env_name: "FL_ENSURE_NO_DEBUG_CODE_TEXT",
                                       description: "The text that must not be in the code base"),
          FastlaneCore::ConfigItem.new(key: :path,
                                       env_name: "FL_ENSURE_NO_DEBUG_CODE_PATH",
                                       description: "The directory containing all the source files",
                                       default_value: ".",
                                       verify_block: Proc.new do |value|
                                        raise "Couldn't find the folder at '#{value}'".red unless File.directory?(value)
                                       end),
          FastlaneCore::ConfigItem.new(key: :extension,
                                       env_name: "FL_ENSURE_NO_DEBUG_CODE_EXTENSION",
                                       description: "The extension that should be searched for. ",
                                       optional: true,
                                       verify_block: Proc.new do |value|
                                        raise "Value must not contain a dot.".red if value.include?"."
                                       end),
        ]
      end

      def self.output
        []
      end

      def self.authors
        ["KrauseFx"]
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end<commit_msg>Improved debug_code detection code<commit_after>module Fastlane
  module Actions
    class EnsureNoDebugCodeAction < Action
      def self.run(params)
        command = "grep -R '#{params[:text]}' '#{File.absolute_path(params[:path])}'"
        Helper.log.info command.yellow
        results = `#{command}` # we don't use `sh` as the return code of grep is wrong for some reason
        return results if Helper.is_test?

        
        # Example Output
        #   ./fastlane.gemspec:  spec.add_development_dependency 'my_word'
        #   ./Gemfile.lock:    my_word (0.10.1)

        found = []
        results.split("\n").each do |current_raw|
          current = current_raw.strip
          if params[:extension]
            if current.include?".#{params[:extension]}:"
              found << current
            end
          else
            found << current
          end
        end

        raise "Found debug code '#{params[:text]}': \n\n#{found.join("\n")}" if found.count > 0
        Helper.log.info "No debug code found in code base 🐛"
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "Ensures the given text is nowhere in the code base"
      end

      def self.details
        [
          "Makes sure the given text is nowhere in the code base. This can be used",
          "to check if there is any debug code still in your code base or if you have",
          "things like // TODO or similar"
        ].join("\n")
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :text,
                                       env_name: "FL_ENSURE_NO_DEBUG_CODE_TEXT",
                                       description: "The text that must not be in the code base"),
          FastlaneCore::ConfigItem.new(key: :path,
                                       env_name: "FL_ENSURE_NO_DEBUG_CODE_PATH",
                                       description: "The directory containing all the source files",
                                       default_value: ".",
                                       verify_block: Proc.new do |value|
                                        raise "Couldn't find the folder at '#{File.absolute_path(value)}'".red unless File.directory?(value)
                                       end),
          FastlaneCore::ConfigItem.new(key: :extension,
                                       env_name: "FL_ENSURE_NO_DEBUG_CODE_EXTENSION",
                                       description: "The extension that should be searched for",
                                       optional: true,
                                       verify_block: Proc.new do |value|
                                        value.gsub!(".", "") if value.include?"."
                                       end),
        ]
      end

      def self.output
        []
      end

      def self.authors
        ["KrauseFx"]
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11781275890637945, 'fraction_numerical': 0.0016570008285004142, 'mean_word_length': 1.362426614481409, 'pattern_counts': {'":': 0, '<': 13, '<?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': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7649738', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1444, 'n_words': 428}