KogenCredo.Check.Readability.MapGetAtomKey (KogenCredo v0.1.0)
View SourceBasics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
Define the shape once (defstruct with defaults) and use x.key, or pattern-match the required key.
Map.get(x, :key) on a map you control hides missing keys and typos.
Check-Specific Parameters
Use the following parameters to configure this check:
:included_paths
Only files under these path prefixes are checked.
This parameter defaults to ["lib/"].
:excluded_paths
Files under these path prefixes are skipped.
This parameter defaults to [].
:flag_with_default
Also report Map.get(x, :key, default).
This parameter defaults to true.
:ignored_receivers
Variable or field names that are never reported as receivers.
This parameter defaults to [:opts, :options, :kw, :keyword, :overrides, :assigns, :attrs, :params, :config, :metadata, :errors, :private].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.