on jam@fix-docs help sign in
patch/test/hlint.hs
38 lines 1.2 kB history raw
1module Main where
3import Control.Monad
4import Language.Haskell.HLint3 (hlint)
5import System.Directory
6import System.Exit (exitFailure, exitSuccess)
7import System.FilePath
8import System.FilePath.Find
10main :: IO ()
11main = do
12 pwd <- getCurrentDirectory
13 let runHlint f = hlint $ f:
14 [ "--ignore=Redundant do"
15 , "--ignore=Use camelCase"
16 , "--ignore=Redundant $"
17 , "--ignore=Use &&"
18 , "--ignore=Use &&&"
19 , "--ignore=Use const"
20 , "--ignore=Use >=>"
21 , "--ignore=Use ."
22 , "--ignore=Use unless"
23 , "--ignore=Reduce duplication"
24 , "--cpp-define=USE_TEMPLATE_HASKELL"
25 , "--ignore=Use tuple-section"
26 ]
27 recurseInto = and <$> sequence
28 [ fileType ==? Directory
29 , fileName /=? ".git"
30 ]
31 matchFile = and <$> sequence
32 [ extension ==? ".hs"
33 ]
34 files <- find recurseInto matchFile (pwd </> "src") --TODO: Someday fix all hints in tests, etc.
35 ideas <- fmap concat $ forM files $ \f -> do
36 putStr $ "linting file " ++ drop (length pwd + 1) f ++ "... "
37 runHlint f
38 if null ideas then exitSuccess else exitFailure