ndmitchell / weeder

Detect dead exports or package imports
BSD 3-Clause "New" or "Revised" License
124 stars 8 forks source link

False negative on executable's redundant build-depends used in library #21

Closed bucklereed closed 7 years ago

bucklereed commented 7 years ago

File test-weeder-example.cabal:

name:                test-weeder-example
version:             0.1.0.0
cabal-version:       >=1.10

library
  hs-source-dirs:      src
  default-language:    Haskell2010
  exposed-modules:  Foo
  build-depends:
      base >=4.9 && < 5
    , containers

executable bar
  hs-source-dirs:      bar
  main-is:             Main.hs
  default-language:    Haskell2010
  build-depends:
      base >= 4.9 && < 5
    , test-weeder-example
    , containers

File src/Foo.hs:

module Foo (foo) where

import qualified Data.Map as Map

fooData = Map.singleton "foo" True

foo :: Maybe Bool
foo = Map.lookup "foo" fooData

File bar/Main.hs:

module Main where

import Foo (foo)

main = print foo

weeder does not detect that the containers dep on the executable is redundant; I assume this is because it's actually being used by the library, and weeder's somehow getting confused about the transitive dependency between the local components.

ndmitchell commented 7 years ago

Thanks for the report. See also #22 which is a generalised description of the issue, lacking a test case.

ndmitchell commented 7 years ago

I believe weeder-0.1.7 should fix this issue. I didn't actually try with the example above (various issues meant that wasn't trivial), but did add something I think is capturing the essence of the problem to my test suite, and that got detected afresh.