Search documentation of Metastatic

# Metastatic.Analysis.ApiSurface (Metastatic v0.13.2)

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

### Types

result()

### Functions

analyze(doc)

Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.

analyze!(doc)

Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.

## Types

# result()

    @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

# analyze(doc)

    @spec analyze(Metastatic.Document.t()) :: {:ok, term()} | {:error, term()}

Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.

# analyze!(doc)

    @spec analyze!(Metastatic.Document.t()) :: term()

Analyzes a document for Metastatic.Analysis.ApiSurface, raising on error.

Unlike not-banged version, this one either returns a result or raises