Search documentation of Metastatic

# Metastatic.Analysis.Complexity.Formatter (Metastatic v0.2.0)

View Source

Formats complexity analysis results for different output formats.

Supports three output formats:

- `:text` - Human-readable text format with ANSI colors
- `:json` - Machine-readable JSON format
- `:detailed` - Extended text format with recommendations

# Summary

## Functions

format(result, atom)

Formats a complexity result in the specified format.

# Functions

# format(result, atom)

    @spec format(Metastatic.Analysis.Complexity.Result.t(), atom()) :: String.t()

Formats a complexity result in the specified format.

## Formats

- `:text` - Default human-readable format
- `:json` - JSON format for programmatic use
- `:detailed` - Extended format with analysis breakdown

## Examples

    iex> result = Metastatic.Analysis.Complexity.Result.new(%{
    ...>   cyclomatic: 5,
    ...>   cognitive: 7,
    ...>   max_nesting: 2,
    ...>   halstead: %{volume: 100.0, difficulty: 5.0, effort: 500.0},
    ...>   loc: %{logical: 20, physical: 30},
    ...>   function_metrics: %{statement_count: 20, return_points: 1, variable_count: 5}
    ...> })
    iex> output = Metastatic.Analysis.Complexity.Formatter.format(result, :text)
    iex> String.contains?(output, "Cyclomatic Complexity")
    true