ElmX re-written - v1.1.0 - Edge Cases now handled

Hello,

In response to the feedback provided by @lydell & @wolfadex I’ve completely re-written ElmX in order to handle the edge-cases they pointed out.

Rather than the initial, rather naive approach, ElmX now starts from the entry module and follows all the imports down each branch in order to build up knowledge of the application structure. This is then compared to the list of all elm files found in order to extract the unused modules.

This means that any and all cyclical modules that are not imported by any used modules are found correctly in a single pass.

Import statements are now extracted correctly when defined across multiple lines, and also comments in and around import statements do not prevent the import statement from being extracted correctly.

source-directories in elm.json is used to ensure correct identification of [unused] modules.

For full details of all the fixes and additions, please see the CHANGELOG.

For full details regarding installation and usage, please see the README.

At the moment, only elm projects of type application are supported. I’m hoping to add support for packages within a couple of days, hopefully tomorrow, (which is now actually later today :joy:, time allowing), and then I’ll be starting on the features TODO list that is detailed at the bottom of the README.

I have only run this against small projects comprising a couple of hundred modules, I would love to hear how it performs on larger projects.

You can run elmx unused-modules -s in order to simply show any unused modules found, so this is completely non-invassive. You must add the -d flag in order for any modules to actually be deleted.

As always, feedback, suggestions and constructive criticism are all welcome.

Thanks for reading :slight_smile:

6 Likes

v1.1.1 now supports Elm Packages.

1 Like

Well done! :clap:

I very quickly looked at some of the code, but was too lazy to actually run it. Here’s a thing I wonder: Does it support {- nested {- comments -} -}, {- comments -}{- next to each other -} and import{-nospace-}Something? (Some annoying comment edge cases, that is.)

1 Like

Not yet

Yes

Yes

I’ve just started work on unused imports, will look into nested comments when I’ve finished this feature, which shouldn’t take long :slight_smile:

1 Like

Er, it might take a while, or at least a bit longer than I initially considered.

I’m probably going to build up some objects that represent all the Elm types and functions that are found after parsing each module, and use that information to do the discovery work.

More to follow…

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.