jfmengels/elm-review-unused

NoUnused.Parameters: Detect unused recursive parameters even when used in let declarations

Open

#98 opened on Dec 12, 2025

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Elm (14 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (26 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Currently, NoUnused.Parameters reports unused recursive parameters, that are only used as values passed to recursive calls. For instance:

foo x unused =
    if condition x then
        x
    else
        foo (x - 1) unused
--> AFTER
foo x =
    if condition x then
        x
    else
        foo (x - 1)

However, the detection stops working when a let declaration is used in the middle:

foo x unused =
    if condition x then
        x
    else
        let
            useless = unused -- or a more complex expression
        in
        foo (x - 1) unused

I would like it if we were to still report an error, and autofix the issue. The autofix would in this example have to remove both the parameter and the declaration for useless, resulting in the same code as in the first example's "after".

Rough idea

I guess we'd need to create some graph of how each value flows and is used. The idea being that we can determine that the second argument flows only into useless, back into only the second argument. Maybe there are better ways to do this though, I haven't thought about this enough!

I've created the recursive-through-variables branch that has a failing test case for feature.

Contributor guide