Metastatic.Analysis.ApiSurface
(Metastatic v0.10.4)
View Source
API surface analysis for containers (modules/classes).
Analyzes the public interface, measuring complexity, consistency, and design quality.
Metrics
- Surface Size: Number of public methods/properties
- Parameter Complexity: Average parameters per public method
- Return Complexity: Variety of return types
- Naming Consistency: Consistent naming patterns
- Interface Cohesion: How focused the API is
Examples
# Small, focused API
ast = {:container, :class, "Stack", %{}, [
{:function_def, :public, "push", ["item"], %{}, ...},
{:function_def, :public, "pop", [], %{}, ...}
]}
doc = Document.new(ast, :python)
{:ok, result} = ApiSurface.analyze(doc)
result.surface_size # => 2
result.assessment # => :excellent
Summary
Functions
Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.
Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.
Types
@type result() :: %{ container_name: String.t() | nil, surface_size: non_neg_integer(), public_methods: [String.t()], avg_params: float(), max_params: non_neg_integer(), assessment: :excellent | :good | :fair | :poor, warnings: [String.t()], recommendations: [String.t()] }
Functions
@spec analyze(Metastatic.language(), term(), keyword()) :: {:ok, map()} | {:error, term()}
Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.
@spec analyze!(Metastatic.language(), term(), keyword()) :: map()
Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.
Unlike not-banged version, this one either returns a result or raises