Assay.Runner (assay v0.6.1)

Copy Markdown View Source

Executes incremental Dialyzer runs directly via :dialyzer.run/1.

Summary

Functions

Runs incremental Dialyzer and returns structured diagnostics without printing.

Types

run_result()

@type run_result() :: :ok | :warnings

Functions

analyze(config, opts \\ [])

@spec analyze(
  Assay.Config.t(),
  keyword()
) :: %{
  status: run_result(),
  warnings: [Assay.Ignore.entry()],
  ignored: [Assay.Ignore.entry()],
  ignore_path: binary() | nil,
  options: keyword(),
  timings: map()
}

Runs incremental Dialyzer and returns structured diagnostics without printing.

This function is useful when you need programmatic access to Dialyzer results without formatted output. It compiles the project (unless :no_compile is set), runs Dialyzer, decorates warnings with metadata, and applies ignore rules.

Options

  • :no_compile - When true, skip the Mix.Task.run("compile") step. The project must already be compiled or Dialyzer will fail. Defaults to false.
  • :quiet - Suppress informational output. Defaults to false.
  • :formats - List of output format atoms. Defaults to [:text].
  • :explain_ignores - Show details about ignored warnings. Defaults to false.
  • :print_config - Print the effective Dialyzer configuration. Defaults to false.

Return Value

Returns a map with:

  • :status - :ok if no warnings, :warnings if warnings found
  • :warnings - List of visible (non-ignored) warning entries
  • :ignored - List of ignored warning entries
  • :ignore_path - Path to the ignore file used, or nil
  • :options - Dialyzer options that were used

Examples

# Analyze with default options
config = Assay.Config.from_mix_project()
result = Assay.Runner.analyze(config)
result.status
# => :ok or :warnings
length(result.warnings)
# => number of visible warnings

# Analyze quietly (no output)
result = Assay.Runner.analyze(config, quiet: true)
# Returns same structure but without printing

# Skip compilation (project must already be compiled)
result = Assay.Runner.analyze(config, no_compile: true)

# Analyze with specific formats (for structured output)
result = Assay.Runner.analyze(config, formats: [:json])
# Then format warnings yourself
json_warnings = Enum.map(result.warnings, fn warning ->
  Assay.Formatter.format([warning], :json, project_root: config.project_root)
end)

run(config, opts \\ [])

@spec run(
  Assay.Config.t(),
  keyword()
) :: run_result()