One mutant: a single mutation applied at a single source location.
One source expression may produce several sites, one for each replacement. Each site records its id, source range, mutator, replacement kind, before/after code, ignore state, and optional variant or advisory note. Mutare.transform_string/2 returns sites alongside the generated metamutant source.
A runner may defer rendering original_code and mutated_code, leaving them nil until the result needs to be displayed. summary may hold a cheaper one-line description for live progress. Mutare.transform_string/2 renders the code fields by default.
Summary
Functions
Builds a lifted deletion site for a function clause.
Returns a one-line description of a site.
Builds a site for a node replacement delivered by an in-place selector.
Builds an in-place deletion site for a rescue clause.
Builds a site for a node replacement delivered through function lifting.
Builds an in-place site for a return-expression replacement.
Returns the live-progress description for a site.
Types
@type t() :: %Mutare.Site{ block_macro: {atom(), non_neg_integer()} | nil, column: pos_integer() | nil, file: String.t(), id: pos_integer(), ignore_reason: String.t() | nil, ignored: boolean(), kind: :in_place | :lifted, line: pos_integer() | nil, mutated_code: String.t() | nil, mutated_form: atom() | nil, mutator: atom(), note: String.t() | nil, operation: :replace | :delete, original_code: String.t() | nil, original_form: atom() | nil, poisoned: boolean(), range: Sourceror.Range.t() | nil, summary: String.t() | nil, variant: [String.t()] }
Functions
@spec clause_drop( pos_integer(), String.t(), Sourceror.Range.t(), Macro.t(), keyword() ) :: t()
Builds a lifted deletion site for a function clause.
The site is recorded under the clause_drop family. :render? defaults to
true; :summary? defaults to false.
Returns a one-line description of a site.
iex> Mutare.Site.describe(%Mutare.Site{
...> mutator: :relational,
...> operation: :replace,
...> original_code: "a >= b",
...> mutated_code: "a > b"
...> })
"relational a >= b → a > b"
iex> Mutare.Site.describe(%Mutare.Site{
...> mutator: :clause_drop,
...> operation: :delete,
...> original_code: "def f(_), do: :ok"
...> })
"clause_drop (drop) def f(_), do: :ok"
@spec in_place( pos_integer(), String.t(), Sourceror.Range.t(), Macro.t(), Macro.t(), Mutare.Mutator.Spec.t(), keyword() ) :: t()
Builds a site for a node replacement delivered by an in-place selector.
range identifies the original node. The recorded family name comes from
mutator.
Options:
:note— advisory text shown in reports:variant— one or more ignore labels; when absent, the mutator callback derives the variant:render?— renderoriginal_codeandmutated_codeimmediately; defaults totrue:summary?— build the lightweight live-progress summary; defaults tofalse
@spec in_place_drop( pos_integer(), String.t(), Sourceror.Range.t(), Macro.t(), Mutare.Mutator.Spec.t(), keyword() ) :: t()
Builds an in-place deletion site for a rescue clause.
mutator supplies the recorded family name. The deleted clause has no mutated
AST or replacement code.
@spec lifted_replace( pos_integer(), String.t(), Sourceror.Range.t(), Macro.t(), Macro.t(), Mutare.Mutator.Spec.t(), keyword() ) :: t()
Builds a site for a node replacement delivered through function lifting.
Lifted delivery is used where an in-place selector is not legal, including guards
and clause-head patterns. The site records kind: :lifted. Options are the same
as for in_place/7.
@spec return_value( pos_integer(), String.t(), Sourceror.Range.t(), Macro.t(), Macro.t(), Mutare.Mutator.Spec.t(), keyword() ) :: t()
Builds an in-place site for a return-expression replacement.
The recorded family name comes from mutator. :render? controls immediate
source rendering and defaults to true; :summary? controls the live-progress
summary and defaults to false.
Returns the live-progress description for a site.
Uses the lightweight summary when present and otherwise falls back to
describe/1.