One problem found by Composer.Lint: what is wrong, how bad it is, and
where.
The shape follows an LSP Diagnostic, so an editor integration only has
to translate it:
severity-:erroror:warningcode- the reason's tag (:typo,:missing_step,:cycle,:unused_alias, ...). Codes are public and stable; they are listed in the lint guide.file- an absolute path, ornilwhen nothing can be locatedline,column- where the problem starts;end_line,end_column- where it ends (exclusive).nilwhen only the file is known.message- the full text ofComposer.Error.message/1reason- the raw reason tuplesuggestions- replacement references, from thetypo,missing_stepandmissing_recipereasonsrelated- other places involved, as%{file, range, message}(the other origin of aconflicting_install, each hop of acycle, the first key of aduplicate_recipe, ...)
Positions
Lines and columns are 1-based. Columns count characters as Elixir's
tokenizer does (grapheme clusters), not bytes or UTF-16 code units. When
column is set, end_line and end_column are set too. A range is
{{line, column}, {end_line, end_column}}.
Summary
Functions
The diagnostic code of a reason: its tag.
True for an error.
Places a diagnostic: in file, over range (or at no particular
position when range is nil), with related locations.
An unlocated diagnostic for reason.
The diagnostic's range, or nil.
The suggested replacements carried by a reason (typo, missing_step,
missing_recipe, also behind a cookbook alias).
The diagnostic as JSON-ready data. reason is left out: tuples do not
encode.
Types
@type position() :: {pos_integer(), pos_integer()}
@type t() :: %Composer.Lint.Diagnostic{ code: atom(), column: pos_integer() | nil, end_column: pos_integer() | nil, end_line: pos_integer() | nil, file: Path.t() | nil, line: pos_integer() | nil, message: String.t(), reason: term(), related: [related()], severity: :error | :warning, suggestions: [String.t()] }
Functions
The diagnostic code of a reason: its tag.
True for an error.
Places a diagnostic: in file, over range (or at no particular
position when range is nil), with related locations.
An unlocated diagnostic for reason.
The diagnostic's range, or nil.
The suggested replacements carried by a reason (typo, missing_step,
missing_recipe, also behind a cookbook alias).
The diagnostic as JSON-ready data. reason is left out: tuples do not
encode.