Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive #89

Open
bhoudebert opened this issue Oct 12, 2021 · 5 comments
Open

False positive #89

bhoudebert opened this issue Oct 12, 2021 · 5 comments

Comments

@bhoudebert
Copy link

bhoudebert commented Oct 12, 2021

I am facing an issue with weeder, it literally says that all of my functions are unused.

Version used:

  • weeder 2.2.0
  • ghc 8.10.7
  • linux + nix

It was working fine a couple of weeks ago and I just discover this weird behavior during:

  • ghc upgrade (8.10.3)
  • migration a simple nix project to haskell.nix
  • moving back from stack to cabal

The hie files are well generated, HLS is able to use them correctly in my editor (so they should be fine).

I end up trying differents configs in the dhall without any success, from my old configuration to the default one propose in this repo.

By chance do you have any tips or hint about this weird situation?

@ocharles
Copy link
Owner

Can you share you weeder Dhall config, along with sample weeds and why you think they are false positives?

@bhoudebert
Copy link
Author

bhoudebert commented Oct 13, 2021

First, thanks for helping me.

I used several different dhall file without any different behavior, last/current one is:

{ roots =
    [ "^Main.main$" ],
    type-class-roots = True
}

It really list every functions of the whole program. As the program is somehow small (just a couple of files), it is easy for me to verify that weeder is wrong. For example, -Wunused-top-binds does not see anything. Most important, like I said in the beginning,weeder before migrations was fine with the code.

Here is also some extra informations.

What is weird is the output of weeder:

src/Business.hs:82: logUserMonthSimulation
src/Business.hs:63: processMonth
src/Business.hs:29: processingBalances
src/Business.hs:56: processingConduit
src/Business.hs:95: updateUserForMonth

and it stops there, without any detail or number of weeds but the program exit with a 1 (echo $?)

If I compare with another project (different version of everything, weeder, stack, ghc)

(...)
src/Commons/Model/User/Permission.hs:16:1: error: allWritePermissions is unused

      14 ┃ 
      15 ┃ allWritePermissions :: [PowerUser] -> [Permission]
      16 ┃ allWritePermissions = fmap Write

    Delete this definition or add ‘Commons.Model.User.Permission.allWritePermissions’ as a root to fix this error.
Weeds detected: 8

If there is not dead code on the second project obvioulsy the output of weeder is Weeds detected: 0

NB: note that for some reason I had to position export LC_ALL=C.UTF-8 in order to run correctly weeder (on the second project) otherwise it fails on parsing file. On the first project doing that will not produce anything.

The difference of weeder behavior on the first project is very weird and as I do not get the number of weeds maybe it could tell us that it crash?

@shapr
Copy link

shapr commented Oct 21, 2021

I'm also getting some definite false positives with ghc 8.10.7 and weeder 2.1.3 , but in a proprietary codebase.
I'll check some of our public repos and see if I can reproduce it there.

@bhoudebert
Copy link
Author

Any news over here?

@ocharles
Copy link
Owner

Sorry, I haven't had a chance to look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants