stil4m/elm-analyse

elm-lang/core reported as unused dependency in basic Elm program

Closed this issue · 3 comments

Trying out elm-analyse for the first time on a Hello world size program (the one generated by create-elm-app), but getting this error:

Cached package information invalidated. Fetching new data from package.elm-lang.org
Fetched dependencies
INFO: Load dependency elm-lang/core 5.1.1
INFO: Load dependency elm-lang/html 2.0.0
INFO: Load file src/Main.elm...

Unused dependencies:
- elm-lang/core

The content of elm-package.json:

{
    "version": "1.0.0",
    "summary": "helpful summary of your project, less than 80 characters",
    "repository": "https://github.com/user/project.git",
    "license": "BSD3",
    "source-directories": [
        "src"
    ],
    "exposed-modules": [],
    "dependencies": {
        "elm-lang/core": "5.1.1 <= v < 6.0.0",
        "elm-lang/html": "2.0.0 <= v < 3.0.0"
    },
    "elm-version": "0.18.0 <= v < 0.19.0"
}

Version of elm-analyse is 0.13.3

Tried to set UnusedDependency to false in checks section of elm-analyse.json, but looking at the source of elm-analyse this check does not seem to be configurable..

elm-lang/core is needed for all Elm programs so I am not sure why this is reported?

Hi Mads, thanks for your bug report. I've looked into it, and it seems that you encountered a bug.

elm-analyse looks at all the imports of each of the source modules, and ticks of all the modules that are used. Since a lot of core modules are imported in prelude, elm-analyse does not detect the dependency on core and marks is incorrectly as unused.

Like you mentioned, core is required by all projects. The fix in elm-analyse would be to whiltelist elm-lang/core.

And unused dependencies is not configurable at this moment. It is not implemented as a check: these are on file level instead of project level.

Thanks again for reporting it.

I'll ship it in 0.14.1. Btw: 0.14.0 was released this weekend, which has a few improvements over the version you are currently using :).

Released in 0.14.1

Thank you for the quick turnaround! 0.14.1 fixes the issue.

Thank you for creating this tool, I look forward to using it more.