dead-code-detection 0.3 → 0.4
raw patch · 3 files changed
+24/−26 lines, 3 filesdep ~getopt-generics
Dependency ranges changed: getopt-generics
Files
- dead-code-detection.cabal +3/−3
- src/Ast/UsedNames.hs +1/−0
- src/Run.hs +20/−23
dead-code-detection.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: dead-code-detection-version: 0.3+version: 0.4 synopsis: detect dead code in haskell projects description: detect dead code in haskell projects category: Development@@ -31,7 +31,7 @@ build-depends: base == 4.* , silently- , getopt-generics+ , getopt-generics == 0.12.* , ghc , Glob , string-conversions@@ -60,7 +60,7 @@ build-depends: base == 4.* , silently- , getopt-generics+ , getopt-generics == 0.12.* , ghc , Glob , string-conversions
src/Ast/UsedNames.hs view
@@ -51,6 +51,7 @@ SigPatIn pat _sig -> usedNames pat BangPat pat -> usedNames pat NPat{} -> []+ LitPat{} -> [] x -> o x instance UsedNames (HsConDetails (LPat Name) (HsRecFields Name (LPat Name))) where
src/Run.hs view
@@ -10,10 +10,9 @@ import Development.GitRev import FastString import GHC-import qualified GHC.Generics import OccName-import System.Console.GetOpt.Generics import System.Exit+import WithCli import Ast import Files@@ -28,31 +27,29 @@ version :: Bool, includeUnderscoreNames :: Bool }- deriving (Show, Eq, GHC.Generics.Generic)+ deriving (Show, Eq, Generic) -instance Generic Options-instance HasDatatypeInfo Options+instance HasArguments Options run :: IO () run = do- options <- modifiedGetArguments $- AddShortOption "sourceDirs" 'i' :- []- when (version options) $ do- putStrLn versionOutput- throwIO ExitSuccess- when (null $ root options) $- die "missing option: --root=STRING"- files <- findHaskellFiles (sourceDirs options)- deadNames <- deadNamesFromFiles- files- (map mkModuleName (root options))- (includeUnderscoreNames options)- case deadNames of- [] -> return ()- _ -> do- forM_ deadNames putStrLn- exitWith $ ExitFailure 1+ let mods = [AddShortOption "sourceDirs" 'i']+ withCliModified mods $ \ options -> do+ when (version options) $ do+ putStrLn versionOutput+ throwIO ExitSuccess+ when (null $ root options) $+ die "missing option: --root=STRING"+ files <- findHaskellFiles (sourceDirs options)+ deadNames <- deadNamesFromFiles+ files+ (map mkModuleName (root options))+ (includeUnderscoreNames options)+ case deadNames of+ [] -> return ()+ _ -> do+ forM_ deadNames putStrLn+ exitWith $ ExitFailure 1 versionOutput :: String versionOutput =