Documentation
¶
Index ¶
- func MutatorComparison(_ *types.Package, _ *types.Info, node ast.Node) []mutator.Mutation
- func MutatorContextNil(_ *types.Package, info *types.Info, node ast.Node) []mutator.Mutation
- func MutatorErrorGuard(_ *types.Package, info *types.Info, node ast.Node) []mutator.Mutation
- func MutatorErrorfWrap(_ *types.Package, _ *types.Info, node ast.Node) []mutator.Mutation
- func MutatorLogical(_ *types.Package, _ *types.Info, node ast.Node) []mutator.Mutation
- func MutatorRecoverClear(_ *types.Package, _ *types.Info, node ast.Node) []mutator.Mutation
- func MutatorRemoveTerm(_ *types.Package, _ *types.Info, node ast.Node) []mutator.Mutation
- func MutatorStringLiteral(_ *types.Package, _ *types.Info, node ast.Node) []mutator.Mutation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MutatorComparison ¶
MutatorComparison implements a mutator to change comparisons.
func MutatorContextNil ¶ added in v2.6.1
MutatorContextNil replaces context.Context arguments at call sites with nil. Mirrors ooze's context-cancellation operator.
func MutatorErrorGuard ¶ added in v2.6.1
MutatorErrorGuard replaces error-check conditions in if-statements:
if err != nil → if false if err == nil → if true
Inspired by gomu's error-handling mutations.
func MutatorErrorfWrap ¶ added in v2.7.0
MutatorErrorfWrap downgrades the error-wrapping verb in Errorf-style calls:
fmt.Errorf("load config: %w", err) → fmt.Errorf("load config: %v", err)
The mutated message is byte-for-byte identical, but the returned error no longer wraps the cause: errors.Is and errors.As against the original error stop matching. This catches the extremely common pattern where code wraps errors with %w purely out of habit and no test ever unwraps the result — a hallmark of machine-generated Go that looks correct but pins no behaviour.
One mutation is emitted per %w verb in the format string.
func MutatorLogical ¶
MutatorLogical swaps && and || operators.
func MutatorRecoverClear ¶ added in v2.7.0
MutatorRecoverClear neutralises a recover() call by turning it into a typed nil:
if r := recover(); r != nil { ... } → if r := any(nil); r != nil { ... }
recover() returns any, and so does any(nil), so the rewrite type-checks in every context recover() can appear in (assignment, comparison, bare call). The difference is behavioural: the recovered value is always nil, so the guarded recovery branch never runs and a panic propagates instead of being swallowed. Deferred recover blocks are classic untested defensive code — generated "just in case" and never exercised. If this mutant survives, the panic-safety net is dead weight or, worse, silently masking real failures.
func MutatorRemoveTerm ¶
MutatorRemoveTerm implements a mutator to remove expression terms.
func MutatorStringLiteral ¶ added in v2.6.7
MutatorStringLiteral zeros non-empty string literals in equality and inequality comparisons (== and !=). This tests whether the exact string value matters — e.g. if err.Error() == "not found" where "" would pass when no error occurs but fail when the specific message is expected.
Scoped to comparisons only to avoid high-noise mutations in log messages, metric names, and other strings whose values are not asserted by tests.
Types ¶
This section is empty.