Encodes Dialyzer warnings to JSON-serializable maps.
Dialyzer warnings come as tuples:
{tag, {file, location}, {warning_type, args}}
This module converts them to structured maps suitable for JSON encoding.
Summary
Types
JSON-serializable warning map
Location can be line number or {line, column}
A raw Dialyzer warning tuple
Functions
Encodes a single Dialyzer warning to a JSON-serializable map.
Encodes a list of Dialyzer warnings to JSON-serializable maps.
Types
@type encoded_warning() :: %{ file: String.t(), line: non_neg_integer(), column: non_neg_integer() | nil, warning_type: String.t(), message: String.t(), raw_message: String.t(), function: String.t() | nil, module: String.t() | nil, fix_hint: String.t() }
JSON-serializable warning map
@type location() :: non_neg_integer() | {non_neg_integer(), non_neg_integer()}
Location can be line number or {line, column}
A raw Dialyzer warning tuple
Functions
@spec encode_warning(warning()) :: encoded_warning()
Encodes a single Dialyzer warning to a JSON-serializable map.
Example
iex> warning = {:warn_return_no_exit, {~c"lib/foo.ex", 10}, {:no_return, [:only_normal, :bar, 2]}}
iex> encoded = DialyzerJson.WarningEncoder.encode_warning(warning)
iex> encoded.file
"lib/foo.ex"
iex> encoded.warning_type
"no_return"
iex> encoded.function
"bar/2"
@spec encode_warnings([warning()]) :: [encoded_warning()]
Encodes a list of Dialyzer warnings to JSON-serializable maps.
Examples
warnings = [{:warn_return_no_exit, {'lib/foo.ex', 10}, {:no_return, [:only_normal, :foo, 2]}}]
encode_warnings(warnings)
[%{file: "lib/foo.ex", line: 10, warning_type: "no_return", ...}]