Credence.Pattern.NoRedundantBinarySyntax (credence v0.5.0)

Copy Markdown

Detects string literals needlessly wrapped in <<>> binary syntax.

In Elixir, strings are already UTF-8 encoded binaries. Wrapping a string literal in <<>> is completely redundant — <<"hello">> is identical to "hello". LLMs often add this wrapper when working with graphemes or character lists, carrying over intuitions from languages where strings and byte sequences are distinct types.

Bad

<<"hello">>
[<<"b">>, <<"a">>, <<"n">>]

Good

"hello"
["b", "a", "n"]

What is flagged

Any <<>> binary form containing a single string literal with no type specifiers. Multi-segment binaries (<<"a", "b">>), byte values (<<1, 2, 3>>), and typed segments (<<x::utf8>>, <<"a"::binary>>) are not flagged.

Sigil internals (~r/pattern/, ~s(text), ~w(words), etc.) are never flagged — their <<>> nodes are AST implementation details, not user-written binary syntax.

Auto-fix

Unwraps the string literal by removing the surrounding << and >>.