Mutare.Mutators.ConventionAtom (mutare v0.1.1)

Copy Markdown View Source

Replaces convention atoms with a compatible alternative:

  • {:ok, payload}{:error, reason} — both 2-tuples
  • {:cont, acc}{:halt, acc} — both 2-tuples (Enum.reduce_while, Stream.transform)
  • :lt:gt — bare comparison results

These atoms are excluded from Mutare.Mutators.AtomLiteral, so only the compatible replacement is emitted. :eq remains under AtomLiteral. OTP return tags such as :reply, :noreply, and :stop are not included because changing only the tag can produce an invalid return tuple.

Configurable

Add application-specific pairs with the :pairs option:

[mutators: [..., {Mutare.Mutators.ConventionAtom, pairs: [[:active, :inactive]]}]]

Custom pairs extend the built-in pairs; they do not replace them. For example, pairs: [[:ok, :okay]] makes :ok mutate to both :error and :okay.

Set call_option_keys: false to skip atoms used as call-option names without changing ordinary atom values:

{Mutare.Mutators.ConventionAtom, call_option_keys: false}

The family applies in value positions and patterns, but not where an atom names a function. An :ok that is a unit-returning function's return tail — every return path of every clause literally :ok or nil, and the function not a behaviour callback — is not a value position and is left alone; there the atom spells "no value", not data (see the exclusions in Mutare.Mutators.ReturnValue). It is enabled by default.

Summary

Functions

Returns the built-in convention atoms.

Functions

members()

@spec members() :: [atom()]

Returns the built-in convention atoms.

Mutare.Mutators.AtomLiteral excludes these atoms so this family can replace them with their configured convention sibling.