<commit_before># frozen_string_literal: true

module Bundle
  module Checker
    class Base
      PACKAGE_TYPE = :pkg
      PACKAGE_TYPE_NAME = "Package"

      NO_ACTION = [].freeze

      def action_required_for(formula)
        [formula]
      end

      def exit_early_check(packages)
        work_to_be_done = packages.find do |pkg|
          yield pkg
        end
        if work_to_be_done
          action_required_for(work_to_be_done)
        else
          NO_ACTION
        end
      end

      def full_check(packages)
        packages.reject { |f| installed_and_up_to_date? f }
                .map { |entry| "#{self.class::PACKAGE_TYPE_NAME} #{entry} needs to be installed or updated." }
      end

      def select_checkable(entries)
        entries.select { |e| e.type == self.class::PACKAGE_TYPE }
      end

      def installed_and_up_to_date?(_pkg)
        raise "unimplemented"
      end

      def find_actionable(entries)
        requested = select_checkable entries

        if Bundle::Commands::Check.exit_on_first_error?
          exit_early_check(requested) { |pkg| !installed_and_up_to_date?(pkg) }
        else
          full_check requested
        end
      end
    end

    module_function

    NO_ACTION = [].freeze

    def action_required_for(formula)
      [formula]
    end

    def exit_early_check(packages)
      work_to_be_done = packages.find do |pkg|
        yield pkg
      end
      if work_to_be_done
        Bundle::Checker.action_required_for(work_to_be_done)
      else
        Bundle::Checker::NO_ACTION
      end
    end

    CheckResult = Struct.new :work_to_be_done, :completed_checks, :errors, :unchecked_checks

    CHECKS = {
      taps_to_tap: "Taps",
      casks_to_install: "Casks",
      apps_to_install: "Apps",
      formulae_to_install: "Formulae",
    }.freeze

    def check(exit_on_first_error)
      @dsl ||= Bundle::Dsl.new(Bundle.brewfile)

      check_method_names = CHECKS.keys

      completed_checks = []
      errors = []
      enumerator = exit_on_first_error ? :any? : :map
<commit_msg>Drops unused early exit check from module since it's in the class<commit_after># frozen_string_literal: true

module Bundle
  module Checker
    class Base
      PACKAGE_TYPE = :pkg
      PACKAGE_TYPE_NAME = "Package"

      NO_ACTION = [].freeze

      def action_required_for(formula)
        [formula]
      end

      def exit_early_check(packages)
        work_to_be_done = packages.find do |pkg|
          yield pkg
        end
        if work_to_be_done
          action_required_for(work_to_be_done)
        else
          NO_ACTION
        end
      end

      def full_check(packages)
        packages.reject { |f| installed_and_up_to_date? f }
                .map { |entry| "#{self.class::PACKAGE_TYPE_NAME} #{entry} needs to be installed or updated." }
      end

      def select_checkable(entries)
        entries.select { |e| e.type == self.class::PACKAGE_TYPE }
      end

      def installed_and_up_to_date?(_pkg)
        raise "unimplemented"
      end

      def find_actionable(entries)
        requested = select_checkable entries

        if Bundle::Commands::Check.exit_on_first_error?
          exit_early_check(requested) { |pkg| !installed_and_up_to_date?(pkg) }
        else
          full_check requested
        end
      end
    end

    module_function

    CheckResult = Struct.new :work_to_be_done, :completed_checks, :errors, :unchecked_checks

    CHECKS = {
      taps_to_tap: "Taps",
      casks_to_install: "Casks",
      apps_to_install: "Apps",
      formulae_to_install: "Formulae",
    }.freeze

    def check(exit_on_first_error)
      @dsl ||= Bundle::Dsl.new(Bundle.brewfile)

      check_method_names = CHECKS.keys

      completed_checks = []
      errors = []
      enumerator = exit_on_first_error ? :any? : :map

{'fraction_non_alphanumeric': 0.08106694560669456, 'fraction_numerical': 0.0, 'mean_word_length': 2.3552631578947367, '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': '4187890', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1213, 'n_words': 251}