# `Juggernaut.Ignore`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/ignore.ex#L1)

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.

# `comment`

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

# `issue`

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

# `parsed`

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

# `parse`

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

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

# `resolve`

```elixir
@spec resolve(
  [Juggernaut.Ignore.Directive.t()],
  pos_integer(),
  atom(),
  String.t() | nil
) ::
  {non_neg_integer(), Juggernaut.Ignore.Directive.t()} | nil
```

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`

```elixir
@spec to_mutant_ignore(Juggernaut.Ignore.Directive.t()) :: Juggernaut.Mutant.ignore()
```

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

# `unused`

```elixir
@spec unused([Juggernaut.Ignore.Directive.t()], MapSet.t(non_neg_integer())) :: [
  issue()
]
```

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
