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
20 stars 9 forks source link

correctly fix List.concat of only list literals in pipeline #119

Closed lue-bird closed 1 year ago

lue-bird commented 1 year ago

Whenever we currently provide a fix for List.concat [ [ ...], ..., [ ... ] ], we merge the elements and remove the List.concat function reference.

So whenever there was a pipeline like List.concat <| [[1,2,3],[4,5,6]], the fix source code would not compile:

I was unable to parse the source code after applying the fixes. Here is
the result of the automatic fixing:

  ```
    module A exposing (..)
    a =  <| [1,2,3,4,5,6]

  ```

This is problematic because fixes are meant to help the user, and applying
this fix will give them more work to do. After the fix has been applied,
the problem should be solved and the user should not have to think about it
anymore. If a fix can not be applied fully, it should not be applied at
all.

The fix in this PR uses keepOnlyFix with the range of list arg to solve this and adds tests to verify pipelines work correctly now.

One extra thing this PR contains which is only slighly related: For concatMap f [ one ] the tests had wrong names and were missing some cases. I couldn't let them sit there :)