No Successive Maps

View Source

Successive map expressions should be avoided.

Avoid

[#{a => 1}
 #{b => 2}]

Prefer

[#{a => 1,
   b => 2}].

Rationale

While writing successive map expressions like #{a => 1} #{b => 2} is syntactically valid, it is almost always a sign of a mistake or unclear intent. Erlang treats these as the same expression, which may confuse readers or mislead them into thinking the maps are two expressions. To ensure clarity and correctness, merge the map expressions as in the example provided in "Prefer".

Reference

The idea behind this rule comes from this email by @kvakvs.

Options

  • None.

Example configuration

{elvis_style, no_successive_maps, #{}}