ForgeCredoChecks.ChainedMapGet (forge_credo_checks v0.7.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 higher and works with any version of Elixir.

Explanation

Replace Map.get(a, key) || Map.get(b, key) with boundary normalization.

Why

Chained Map.get/2 calls are a stronger signal than a local default: the caller does not know which input shape it has. Each call site that fishes across multiple maps or key spellings makes the data contract harder to see and easier to drift.

How to fix

# BEFORE
Map.get(context, :issue) || Map.get(arguments, :issue)

# AFTER
normalized = normalize_issue_input(context, arguments)
normalized.issue

Normalize once at the ingestion boundary, then consume a single known shape in the rest of the code.

What NOT to do

Do not add more || Map.get(...) fallbacks locally. That spreads the schema ambiguity instead of removing it.

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.