Juggernaut.Ignore (Juggernaut v0.4.0)

Copy Markdown View Source

Ignore comments (design notes §8.3): Mutare's grammar under each configured prefix (default juggernaut:ignore and mutare:ignore).

  • # <prefix> covers one line: its own line when it follows code, else the next code line, reading through comment lines (a blank line ends the search, and the directive then covers nothing);
  • # <prefix>-start ... # <prefix>-end cover every line between them, both included; regions do not nest;
  • # <prefix>-file covers the whole file.

Right after the verb, an optional [family, family:label, ...] filter, then the reason. A directive matches a mutant when it covers the mutant's first line and the filter is absent or names its family (and, with a label, its variant, case-insensitively). When several match, the most specific filter wins (label, then family, then none), then the narrowest scope (line, region, file), then the earliest comment.

Errors (exit 2): an unpaired or nested region marker, an end marker of another prefix than the open start, an unknown label for a known family, and a juggernaut:ignore directive without a reason (Juggernaut's own prefix requires one; mutare:ignore keeps Mutare's rule). Warnings: a directive that ignores nothing, an unknown family, a malformed filter item (a family not written in lower case letters and underscores, or an empty label or one holding a space or tab) or an empty filter, and a comment that claims a prefix's namespace with an unknown verb (# mutare:ingore). Under strict_ignores warnings are errors too.

Summary

Functions

Parses the directives among comments of a file whose lines are lines.

The directive that ignores a mutant on line of family with variant, or nil. Returns the directive's index in directives too, so callers can track use.

The ignore map of a mutant (Juggernaut.Mutant.ignore).

Warnings for the directives (by index) that ignored no mutant.

Types

comment()

@type comment() :: %{line: pos_integer(), column: pos_integer(), text: String.t()}

issue()

@type issue() :: %{code: atom(), message: String.t(), line: pos_integer()}

parsed()

@type parsed() :: %{
  directives: [Juggernaut.Ignore.Directive.t()],
  errors: [issue()],
  warnings: [issue()]
}

Functions

parse(lines, comments, prefixes)

@spec parse([String.t()], [comment()], [String.t()]) :: parsed()

Parses the directives among comments of a file whose lines are lines.

resolve(directives, line, family, variant)

The directive that ignores a mutant on line of family with variant, or nil. Returns the directive's index in directives too, so callers can track use.

to_mutant_ignore(directive)

The ignore map of a mutant (Juggernaut.Mutant.ignore).

unused(directives, used)

Warnings for the directives (by index) that ignored no mutant.