module Spoom::Deadcode

def load_custom_plugins(context)

: (Context context) -> Array[singleton(Plugins::Base)]
def load_custom_plugins(context)
  context.glob("#{DEFAULT_CUSTOM_PLUGINS_PATH}/*.rb").each do |path|
    require("#{context.absolute_path}/#{path}")
  end
  T.unsafe(ObjectSpace)
    .each_object(Class)
    .select do |klass|
      next unless T.unsafe(klass).name # skip anonymous classes, we only use them in tests
      next unless T.unsafe(klass) < Plugins::Base
      location = Object.const_source_location(T.unsafe(klass).to_s)&.first
      next unless location
      next unless location.start_with?("#{context.absolute_path}/#{DEFAULT_CUSTOM_PLUGINS_PATH}")
      true
    end
end

def plugins_from_gemfile_lock(context)

: (Context context) -> Set[singleton(Plugins::Base)]
def plugins_from_gemfile_lock(context)
  # These plugins are always loaded
  plugin_classes = DEFAULT_PLUGINS.dup
  # These plugins depends on the gems used by the project
  context.gemfile_lock_specs.keys.each do |name|
    plugin_class = PLUGINS_FOR_GEM[name]
    plugin_classes << plugin_class if plugin_class
  end
  plugin_classes
end