rtfeldman / elm-spa-example

A Single Page Application written in Elm
https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa
MIT License
3.28k stars 530 forks source link

Cleanup unused imports and remove dead code #67

Closed klazuka closed 3 years ago

klazuka commented 5 years ago

In version 2.2.0 of intellij-elm we added support for finding unused imports, functions, parameters, and aliases. I ran it against the SPA example app and deleted everything that was unused.

klazuka commented 5 years ago

I described the technique for finding the unused things in a Discourse post.

zwilias commented 5 years ago

@klazuka I was testing the 0.19 upgrade of elm-xref on this project, and ran across some things that apparently weren't caught by intellij-elm. Figured you'd like to know ;)

Have a look at Route.Root: That constructor is only ever used in case .. of patterns, but never constructed. As such, it is unused and can be removed (together with matching cases) without functional impact.

Cheers!

klazuka commented 5 years ago

~Yep, I haven’t yet implemented it for exposed constructors because it will be easier to do once I drop support for 0.18. In 0.19, they can only be exposed by ‘..’ whereas in 0.18 they can also be individually exposed. The former is slightly easier to implement, and I didn’t want to overly complicate the code for the 0.18 case when it will all be ripped out later this year.~

Never mind. The above describes why I punted on tracking constructor usage through imports. Your example doesn’t involve imports at all, and you’re right, it would be nice to check such things.

HenkPoley commented 4 years ago

I have to say that on the current codebase elm-xref gives spurious results.

But the free IntelliJ IDEA CE with 'Elm' and 'Elm External Tools' plugins does identify unused imports and other code, after which the elm-spa-example still compiles 👍