Rbtz.CredoChecks.Warning.SetMimicGlobal (rbtz_credo_checks v0.2.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

Forbids enabling Mimic in global mode (set_mimic_global) inside test files.

set_mimic_global allows mocks to be observed and set from any process, but it forces the test (and every test in its setup_all scope) to run synchronously. Once a single test opts in to global Mimic, the whole test module loses async: true parallelism.

If you genuinely need cross-process mocking, isolate the affected test to its own module and accept the synchronous cost there — don't push it on the rest of the suite.

Bad

setup :set_mimic_global

setup_all :set_mimic_global

Good

setup :verify_on_exit!
# use `set_mimic_private` (the default) and pass mocks to spawned
# processes via `Mimic.allow/3` if needed

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.