jfmengels / elm-review-simplify

Provides elm-review rules to simplify your Elm code
https://package.elm-lang.org/packages/jfmengels/elm-review-simplify/latest/
BSD 3-Clause "New" or "Revised" License
19 stars 9 forks source link

Simplify `case` if all branches are the same #292

Open miniBill opened 7 months ago

miniBill commented 7 months ago

What the rule should do: Simplify case of expressions if all the branches are the same.

Example of things the rule would report:

 case err of
   Http.BadBody _ ->
    Task.fail err
  _ ->
    Task.fail err
--> Task.fail err

(this is real code, and is the result of other simplifications)

Example of things the rule would not report:

case res of
  Ok v -> v
  Err v -> v

Should this be part of the Simplify rule or should it be a new rule? Should be part of Simplify

I am looking for:

jfmengels commented 7 months ago

This is something that we did earlier in the history of the rule and was (partially) removed in v2.0.19 (reasoning in the link). Let me know what you think.

miniBill commented 7 months ago

Ah, makes sense. It should have triggered though, because Http.BadBody comes from a dependency?

jfmengels commented 7 months ago

You're correct 🤔 I'll mark this as a bug, this will need some looking into.