Jump. CredoChecks. NoWordSigilInterpolation
(Jump.CredoChecks v0.7.1)
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
Use an explicit list instead of interpolation inside ~w.
Word sigils split their contents on whitespace after interpolation. Quoting a phrase does not keep it together, and interpolated values can unexpectedly become multiple list items. This is confusing and hard to remember, so it's better to avoid it altogether.
Use an explicit list such as ["name", "net worth", "balance"] when
items require interpolation. This applies to all lowercase ~w modifiers:
strings, atoms, and charlists.
two_names = "john smith"
# ❌ Bad — interpolation splits two_names into separate list items
~w(hello #{two_names} world)
# ✅ Good — two_names stays a single list item
["hello", two_names, "world"]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.