rule : Review.Rule.Rule
Forbids using concatenation (++
and List.concat
) when it's not needed.
Expressions like [ a, b ] ++ c
will be flagged, with a fix proposing to
rewrite that to somethine like a :: b :: c
. This is more performant and makes
it clear that we're talking about consing items to the head of a list. Easy!
Expressions like [ a, b ] ++ [ c, d ]
could be rewritten to a single literal
list: no need to perform the concatenation at runtime when we can just write it
ourselves! So, the fix will propose writing that as [ a, b, c, d ]
.
Expression like List.concat [ [ a ], [ b ], [ c ] ]
could become [ a, b c ]
.
Finally, expressions like "foo" ++ "bar"
can also be "foobar"
.
To use this rule, add it to your elm-review
config like so:
module ReviewConfig exposing (config)
import NoRedundantConcat
import Review.Rule exposing (Rule)
config : List Rule
config =
[ NoRedundantConcat.rule
]