Metastatic.Analysis.Registry
(Metastatic v0.10.4)
View Source
Registry for analyzer plugins.
Manages registration, discovery, and configuration of analyzers. Runs as a GenServer under the application supervision tree.
Usage
# Register an analyzer
Registry.register(MyApp.Analysis.UnusedVariables)
# Look up by name
Registry.get_by_name(:unused_variables)
# Look up by category
Registry.list_by_category(:correctness)
# List all
Registry.list_all()
# Configure analyzer
Registry.configure(MyAnalyzer, %{threshold: 10})Configuration
Auto-register analyzers at application startup:
# config/config.exs
config :metastatic, :analyzers,
auto_register: [
Metastatic.Analysis.UnusedVariables,
Metastatic.Analysis.SimplifyConditional
],
disabled: [:some_analyzer],
config: %{
unused_variables: %{ignore_prefix: "_"}
}
Summary
Functions
Returns a specification to start this module under a supervisor.
Clears all registered analyzers.
Updates configuration for an analyzer.
Gets analyzer by name.
Gets configuration for an analyzer.
Lists all registered analyzers.
Lists analyzers by category.
Lists all available categories.
Registers an analyzer module.
Starts the registry GenServer.
Unregisters an analyzer module.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec clear() :: :ok
Clears all registered analyzers.
Primarily for testing purposes.
Updates configuration for an analyzer.
Merges the new config with existing config.
Examples
iex> Registry.configure(MyAnalyzer, %{threshold: 10})
:ok
Gets analyzer by name.
Returns nil if no analyzer is registered with that name.
Examples
iex> Registry.get_by_name(:unused_variables)
MyApp.Analysis.UnusedVariables
iex> Registry.get_by_name(:nonexistent)
nil
Gets configuration for an analyzer.
Returns empty map if no configuration is set.
Examples
iex> Registry.get_config(MyAnalyzer)
%{threshold: 10}
@spec list_all() :: [module()]
Lists all registered analyzers.
Examples
iex> Registry.list_all()
[MyApp.Analysis.UnusedVariables, MyApp.Analysis.SimplifyConditional]
Lists analyzers by category.
Examples
iex> Registry.list_by_category(:correctness)
[MyApp.Analysis.UnusedVariables, MyApp.Analysis.DeadCode]
@spec list_categories() :: [atom()]
Lists all available categories.
Examples
iex> Registry.list_categories()
[:correctness, :style, :refactoring, :maintainability]
Registers an analyzer module.
The module must implement the Metastatic.Analysis.Analyzer behaviour.
Validates that no conflicts exist (another analyzer with same name).
Examples
iex> Registry.register(MyApp.Analysis.UnusedVariables)
:ok
iex> Registry.register(ConflictingAnalyzer)
{:error, "Analyzer named :unused_variables already registered: ..."}
@spec start_link(keyword()) :: GenServer.on_start()
Starts the registry GenServer.
Called automatically by the application supervision tree.
@spec unregister(module()) :: :ok
Unregisters an analyzer module.
Removes the analyzer from the registry.
Examples
iex> Registry.unregister(MyApp.Analysis.UnusedVariables)
:ok