Shared helpers for turning Dialyzer warning payloads into friendly, Elixir-style
text sections. A handler can take an entry (as delivered by the formatter),
produce a %Result{headline, details}, and lean on these utilities for consistent
indentation, diff highlighting, and term rendering.
Example: using the diff helpers
# Given two one-line specs, render a +/- diff with balanced parens and color.
opts = [color?: true]
expected = ["([integer()]) :: integer() | nil"]
actual = ["(maybe_improper_list()) :: any()"]
Assay.Formatter.Helpers.diff_lines(expected, actual, opts)
# => [
# IO.ANSI.red() <> "- ([integer()]) :: integer() | nil" <>
# IO.ANSI.reset(),
# IO.ANSI.green() <> "+ (maybe_improper_list()) :: any()" <>
# IO.ANSI.reset()
# ]Example: rendering Erlang terms as Elixir-friendly text
Assay.Formatter.Helpers.format_term_lines("%{title => <<116,105,116,108,101>>}")
# => ["%{:title => "title"}"]Handlers that need more control (maps, specs, nested structs) can combine
diff_segments/3, diff_map_entries/3, and format_term_lines/1 to build
domain-specific sections while preserving the same visual language used by
other warnings.
Summary
Functions
Trims Dialyzer prefixes from a reason line.
Convenience wrapper around Assay.Formatter.Helpers.diff_lines/3.
Renders a diff section header plus indented lines.
Extracts the will never return reason line from a Dialyzer entry, if present.
Formats a module/function into Module.fun.
Convenience wrapper around Assay.Formatter.Helpers.format_term_lines/1.
Builds a simple reason block for warning output.
Builds a Result for a raw Dialyzer entry, delegating to handlers when available.
Renders a labeled value block with optional color.
Functions
Trims Dialyzer prefixes from a reason line.
Examples
iex> Assay.Formatter.Warning.clean_reason("-> will never return since types differ")
"will never return since types differ"
Convenience wrapper around Assay.Formatter.Helpers.diff_lines/3.
Examples
iex> result = Assay.Formatter.Warning.diff_lines(["(atom())"], ["(binary())"], color?: false)
iex> List.flatten(result)
["- (atom())", "+ (binary())"]
Renders a diff section header plus indented lines.
Examples
iex> Assay.Formatter.Warning.diff_section(["- (atom())", "+ (binary())"], color?: false)
["", "Diff (expected -, actual +):", " - (atom())", " + (binary())"]
Extracts the will never return reason line from a Dialyzer entry, if present.
Examples
iex> entry = %{text: "lib/foo.ex:1: -> will never return since types differ"}
iex> Assay.Formatter.Warning.extract_reason_line(entry)
"will never return since types differ"
Formats a module/function into Module.fun.
Examples
iex> Assay.Formatter.Warning.format_call(Foo.Bar, :run)
"Foo.Bar.run"
Convenience wrapper around Assay.Formatter.Helpers.format_term_lines/1.
Examples
iex> Assay.Formatter.Warning.format_term_lines("%{title => <<116,105,116,108,101>>}")
["%{title => \"title\"}"]
iex> Assay.Formatter.Warning.format_term_lines("(atom())")
["(atom())"]
Builds a simple reason block for warning output.
Examples
iex> Assay.Formatter.Warning.reason_block("will never return")
["", "Reason:", " will never return"]
@spec render( map(), keyword() ) :: Assay.Formatter.Warning.Result.t()
Builds a Result for a raw Dialyzer entry, delegating to handlers when available.
Examples
iex> entry = %{text: "warning text", match_text: "warning text", path: nil, line: nil, column: nil, code: nil}
iex> Assay.Formatter.Warning.render(entry).headline
"warning text"
Renders a labeled value block with optional color.
Examples
iex> Assay.Formatter.Warning.value_block("Expected", ["(atom())"], color?: false)
["Expected:", " (atom())"]