No Space

View Source

Spaces in specified text positions should be avoided.

Quick fix

Use an Erlang code formatter that enforces strict spacing.

Avoid

Text = (value).
Label = #{key => err}

Prefer

Text = (value).
Label = #{key => err}

Rationale

This rule improves code consistency and formatting by ensuring that specified positions - such as left, or right - of a text string are free from extraneous spaces. Stray leading or trailing whitespace may go unnoticed but can affect string comparisons, display output, or formatting in generated documentation. Enforcing this rule helps prevent subtle issues and maintains a clean codebase.

Options

  • rules :: [{right | left, string()}]

    • default: [{right, "("}, {left, ")"}, {left, ","}, {left, ":"}, {right, "#"}, {right, "?"}, {right, "?"}, {left, "."}, {left, ";"}]

{right, "#"}, {right, "?"} was added in 4.0.0.

{left, "."}, {left, ";"} was added in 4.1.0.

Example configuration

{elvis_style, no_space, #{
    rules => [
        {right, "("},
        {left, ")"},
        {left, ","},
        {left, ":"},
        {right, "#"},
        {right, "?"},
        {right, "?"},
        {left, "."},
        {left, ";"}
    ]
}}