jfmengels/elm-lint/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Lint.Rules.NoUselessPatternMatching

rule : String -> List Error

Reports case expressions that can be simplified. Either when all patterns will lead to the same value, or when a pattern will lead to the same value as the default pattern.

rules =
    [ NoUselessPatternMatching.rule
    ]

Fail

-- Useless pattern matching
case value of
    Foo -> 1
    Bar -> 1
    _ -> 1


-- Useless pattern `Bar`, it's the same as the default pattern
case value of
    Foo -> 2
    Bar -> 1
    _ -> 1

Success

case value of
    Foo -> 1
    Bar -> 2
    _ -> 3


case value of
    Foo n -> n
    Bar n -> n