Rbtz.CredoChecks.Readability.PreferSigilSForEscapedQuotes (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 normal and works with any version of Elixir.

Explanation

Encourages using the ~s sigil when a double-quoted string needs to escape one or more " characters.

~s(...), ~s{...}, and friends let you pick a delimiter that doesn't collide with the string's contents, so the body reads as it will eventually print — no \" noise to parse visually.

Interpolation still works inside ~s, so this is purely a readability swap — no semantic change.

Bad

"Run \"mix test.coverage\" once all exports complete"
~s|He said \"hi\"|

Good

~s(Run "mix test.coverage" once all exports complete)
~s|He said "hi"|

The check inspects every plain double-quoted string literal ("..."). Heredocs, sigils, and charlists are not flagged.

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.