packages feed

weeder 1.0.6 → 1.0.7

raw patch · 6 files changed

+25/−15 lines, 6 files

Files

CHANGES.txt view
@@ -1,5 +1,9 @@ Changelog for Weeder +1.0.7, released 2018-08-23+    Don't warn on base as it is used by Paths_ modules+    #42, make --verbose print out the version number+    #41, make the --help output clear you can pass a stack.yaml 1.0.6, released 2018-06-16     Don't fail with an error if stack setup is necessary     If you fail to find stack.yaml give a better error message
README.md view
@@ -74,3 +74,5 @@ **Declaration QuasiQuotes** If you use a declaration-level quasi-quote then weeder won't see the use of the quoting function, potentially leading to an unused import warning, and marking the quoting function as a weed. The only solution is to ignore the entries with a `.weeder.yaml` file.  **Stack extra-deps** Packages marked extra-deps in your `stack.yaml` will be weeded, due to a bug in [`stack`](https://github.com/commercialhaskell/stack/issues/3258). The only solution is to ignore the packages with a `.weeder.yaml` file.++**Linking to C functions** If a library provides C functions, and these are used directly from another library/executable, the library providing these functions may be marked as a redundant `build-depends`, see [more details](https://github.com/ndmitchell/weeder/issues/40).
src/Check.hs view
@@ -17,7 +17,7 @@ data S = S     {pkg :: PackageName     ,hi :: HiKey -> Hi-    ,sections :: [(CabalSection, ([HiKey], [HiKey]))]+    ,sections :: [(CabalSection, ([HiKey], [HiKey], [ModuleName]))]     }  check :: (HiKey -> Hi) -> PackageName -> [(CabalSection, ([HiKey], [HiKey], [ModuleName]))] -> [Warning]@@ -26,34 +26,35 @@     warnRedundantPackageDependency s ++     warnIncorrectOtherModules s ++     warnUnusedExport s ++-    warnNotCompiled pkg sections2 +++    warnNotCompiled s ++     warnUnusedImport s     where         s = S{..}-        sections = map (second $ \(a,b,c) -> let aa = nubOrd a in (aa,nubOrd b \\ aa)) sections2+        sections = map (second $ \(a,b,c) -> let aa = nubOrd a in (aa,nubOrd b \\ aa,c)) sections2  -warnNotCompiled :: PackageName -> [(CabalSection, ([HiKey], [HiKey], [ModuleName]))] -> [Warning]-warnNotCompiled pkg xs =+warnNotCompiled :: S -> [Warning]+warnNotCompiled S{..} =     [ Warning pkg [cabalSectionType s] "Module not compiled" Nothing (Just m) Nothing-    | (s, (_, _, missing)) <- xs, m <- missing]+    | (s, (_, _, missing)) <- sections, m <- missing]   warnReusedModuleBetweenSections :: S -> [Warning] warnReusedModuleBetweenSections S{..} =     [ Warning pkg ss "Module reused between components" Nothing (Just $ hiModuleName $ hi m) Nothing-    | (m, ss) <- groupSort [(x, cabalSectionType c) | (c, (x1,x2)) <- sections, x <- x1++x2]+    | (m, ss) <- groupSort [(x, cabalSectionType c) | (c, (x1,x2,_)) <- sections, x <- x1++x2]     , length ss > 1]   warnRedundantPackageDependency :: S -> [Warning] warnRedundantPackageDependency S{..} =     [ Warning pkg [cabalSectionType] "Redundant build-depends entry" (Just p) Nothing Nothing-    | (CabalSection{..}, (x1,x2)) <- sections+    | (CabalSection{..}, (x1,x2,_)) <- sections     , let usedPackages = Set.unions $ map (Set.map fst . hiImportPackageModule . hi) $ x1 ++ x2     , p <- Set.toList $ Set.fromList cabalPackages `Set.difference` usedPackages     , p /= if isWindows then "unix" else "Win32" -- ignore packages that must be conditional on the other platform     , p /= "semigroups" -- ignore packages that are often conditional+    , p /= "base" -- used by Paths_ modules which we have thrown away by this point     ]  @@ -61,7 +62,7 @@ warnIncorrectOtherModules S{..} = concat     [ [Warning pkg [cabalSectionType] "Missing other-modules entry" Nothing (Just m) Nothing | m <- Set.toList missing] ++       [Warning pkg [cabalSectionType] "Excessive other-modules entry" Nothing (Just m) Nothing | m <- Set.toList excessive]-    | (CabalSection{..}, (external, internal)) <- sections+    | (CabalSection{..}, (external, internal,_)) <- sections     , let imports = Map.fromList [(hiModuleName, hiImportModule) | Hi{..} <- map hi $ external ++ internal]     , let missing =  Set.filter (not . isPathsModule) $                      Set.unions (Map.elems imports) `Set.difference`@@ -75,7 +76,7 @@ warnUnusedImport :: S -> [Warning] warnUnusedImport S{..} =     [ Warning pkg [cabalSectionType] "Unused import" Nothing (Just $ hiModuleName mod) (Just $ hiModuleName imp)-    | (CabalSection{..}, (external, internal)) <- sections+    | (CabalSection{..}, (external, internal,_)) <- sections     , let mods = Map.fromList $ map ((hiModuleName &&& id) . hi) $ external ++ internal     , mod <- Map.elems mods     , imp <- mapMaybe (`Map.lookup` mods) $ Set.toList $@@ -95,7 +96,7 @@         -- important: for an identifer to be unused, it must be unused in all sections that use that key         unused = unionsWith (\(s1,i1) (s2,i2) -> (s1++s2, i1 `Set.intersection` i2))                  [ Map.fromList [(k, ([cabalSectionType], Set.fromList $ Map.lookupDefault [] (hiModuleName $ hi k) bad)) | k <- internal ++ external]-                 | (CabalSection{..}, (external, internal)) <- sections+                 | (CabalSection{..}, (external, internal,_)) <- sections                  , let bad = Map.fromListWith (++) $ map (identModule &&& return . identName) $ notUsedOrExposed (map hi external) (map hi internal)]  notUsedOrExposed :: [Hi] -> [Hi] -> [Ident]
src/CmdLine.hs view
@@ -35,7 +35,7 @@  mode :: Mode (CmdArgs Cmd) mode = cmdArgsMode $ Cmd-    {cmdProjects = def &= args &= typ "DIR"+    {cmdProjects = def &= args &= typ "DIR OR stack.yaml"     ,cmdBuild = nam "build" &= help "Build the project first"     ,cmdTest = nam "test" &= help "Run the test suite"     ,cmdMatch = nam "match" &= help "Make the .weeder.yaml perfectly match"@@ -43,7 +43,7 @@     ,cmdYaml = nam "yaml" &= help "Output YAML"     ,cmdShowAll = nam "show-all" &= help "Show even ignored warnings"     ,cmdDistDir = nam "dist-dir" &= typDir &= help "Stack dist-dir, defaults to 'stack path --dist-dir'"-    } &= explicit &= name "weeder" &= verbosity-    &= summary ("Weeder v" ++ showVersion version ++ ", (C) Neil Mitchell 2017-2018")+    } &= explicit &= verbosity+    &= name "weeder" &= program "weeder" &= summary ("Weeder v" ++ showVersion version ++ ", (C) Neil Mitchell 2017-2018")     where         nam xs = def &= explicit &= name xs &= name [head xs]
src/Weeder.hs view
@@ -7,6 +7,7 @@ import Hi import Cabal import Stack+import Data.Version import Data.List.Extra import Data.Functor import Data.Tuple.Extra@@ -16,6 +17,7 @@ import qualified Data.HashMap.Strict as Map import System.Directory.Extra import System.FilePath+import Paths_weeder import Check import Warning import CmdLine@@ -27,6 +29,7 @@ weeder :: [String] -> IO Int weeder args = do     cmd@Cmd{..} <- getCmd args+    whenLoud $ putStrLn $ "Weeder version " ++ showVersion version     res <- mapM (weedPath cmd) cmdProjects     return $ sum res 
weeder.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.18 build-type:         Simple name:               weeder-version:            1.0.6+version:            1.0.7 license:            BSD3 license-file:       LICENSE category:           Development