OptimumCredo.Check.Refactor.RepeatedLiteral (OptimumCredo v0.5.0)

View Source

Basics

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

A string literal repeated in a module is a candidate for a named module attribute. Single obvious literals stay inline; this check only counts repeated plain strings outside patterns, attributes, sigils and tests. Opt-in, low priority.

Check-Specific Parameters

Use the following parameters to configure this check:

:min_occurrences

How many identical literals trigger the check.

This parameter defaults to 3.

:min_length

Shortest string that is counted.

This parameter defaults to 3.

:ignore_literals

Strings that are never counted.

This parameter defaults to [].

:ignore_paths

Directory (ending in /) or file-suffix patterns to skip.

This parameter defaults to ["test/", "priv/", "config/", "_test.exs"].

General Parameters

Like with all checks, general params can be applied.

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