jfmengels / elm-review

Analyzes Elm projects, to help find mistakes before your users find them.
https://package.elm-lang.org/packages/jfmengels/elm-review/latest/
Other
252 stars 13 forks source link

Improve automatic fixes #155

Closed jfmengels closed 1 year ago

jfmengels commented 1 year ago

This PR does multiple nice things.

Allows the package code to handle all the kinds of fixes

Ever since fixes were added to the package instead of the CLI, we applied almost all the fixes, but we ignored the ones for elm.json, as those can change the dependencies. Because of that, we kept the logic to apply fixes also in the CLI, which I believe was a source of bugs when it comes to fixes. With this change, the searching for fixes can be removed from the CLI.

Report failed fixes

Checking whether a fix was incorrect was so far only done in the CLI. To keep that nice UX of telling the user when something wrong happened, we now need to compute and return it as part of the API. This PR introduces the new Review.Error.errorFixFailure function to get that information. The last bunch of commits in this PR was about getting this part to work and be cached, which was a bit troublesome and I think I can change this later to not feel as cumbersome.


Apart from that, this also tries to be a bit smarter about finding fixes, like stopping early (well, earlier at least) when a fix is found.