Search documentation of Metastatic

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

View Source

Executes multiple analyzers on a Document in a single pass.

Handles AST traversal, context management, and issue collection.

## Usage

    alias Metastatic.{Document, Analysis.Runner}

    doc = Document.new(ast, :python)

    # Run all registered analyzers
    {:ok, report} = Runner.run(doc)

    # Run specific analyzers
    {:ok, report} = Runner.run(doc,
      analyzers: [MyAnalyzer, AnotherAnalyzer]
    )

    # With configuration
    {:ok, report} = Runner.run(doc,
      analyzers: :all,
      config: %{my_analyzer: %{threshold: 10}}
    )

## Report Structure

The report contains:

- `:document` - The analyzed document
- `:analyzers_run` - List of analyzers that were executed
- `:issues` - All issues found
- `:summary` - Aggregated statistics
- `:timing` - Performance metrics (if enabled)

## Summary

### Types

report()
run_options()

### Functions

run(doc, opts \\ [])

Runs configured analyzers on a document.

run!(doc, opts \\ [])

Runs analyzers, raising on error.

## Types

# report()

    @type report() :: %{
      document: Metastatic.Document.t(),
      analyzers_run: [module()],
      issues: [Metastatic.Analysis.Analyzer.issue()],
      summary: map(),
      timing: map() | nil
    }

# run_options()

    @type run_options() :: [
      analyzers: :all | [module()],
      config: map(),
      halt_on_error: boolean(),
      max_issues: non_neg_integer() | :infinity,
      track_timing: boolean()
    ]

## Functions

# run(doc, opts \\ [])

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

Runs configured analyzers on a document.

## Options

- `:analyzers` - Which analyzers to run (default: `:all` registered)
- `:config` - Configuration map for analyzers
- `:halt_on_error` - Stop on first error severity issue (default: `false`)
- `:max_issues` - Maximum issues to collect (default: `:infinity`)
- `:track_timing` - Include timing information (default: `false`)

## Examples

    iex> doc = Document.new(ast, :python)
    iex> {:ok, report} = Runner.run(doc)
    iex> report.summary.total
    3

    iex> {:ok, report} = Runner.run(doc, analyzers: [UnusedVariables])
    iex> report.analyzers_run
    [Metastatic.Analysis.UnusedVariables]

# run!(doc, opts \\ [])

    @spec run!(Metastatic.Document.t(), run_options()) :: report()

Runs analyzers, raising on error.

## Examples

    iex> report = Runner.run!(doc)
    iex> length(report.issues)
    3