on develop help sign in
change the way we invoke hlint to be more flexible at the file level
commitef4da286bc94d5ea723325b5dee287b73eac33be authorDan Haraj <dan@obsidian.systems> dateMon 5 Jun 2017, 11:58 (9 years ago) parent7709fb1
3 files changed+44−16
default.nix+2−2 reflex.cabal+5−1 test/hlint.hs+37−13
default.nix+2−2
@@ -4,7 +4,7 @@
44, monad-control, mtl, primitive, ref-tf, semigroupoids
55, semigroups, split, stdenv, stm, syb, template-haskell
66, these, transformers, transformers-compat, prim-uniq
7−, data-default
7+, data-default, filepath, directory, filemanip
88, useTemplateHaskell ? true
99}:
1010mkDerivation {
@@ -23,7 +23,7 @@ mkDerivation {
2323 haskell-src-exts haskell-src-meta
2424 ]);
2525 testHaskellDepends = if ghc.isGhcjs or false then [] else [
26− hlint
26+ hlint filepath directory filemanip
2727 ];
2828 configureFlags = if useTemplateHaskell then [] else [
2929 "-f-use-template-haskell"
reflex.cabal+5−1
@@ -175,7 +175,11 @@ test-suite hlint
175175 type: exitcode-stdio-1.0
176176 main-is: hlint.hs
177177 hs-source-dirs: test
178− build-depends: base, hlint == 1.9.*
178+ build-depends: base
179+ , directory
180+ , filepath
181+ , filemanip
182+ , hlint == 1.9.*
179183 if impl(ghcjs)
180184 buildable: False
181185
test/hlint.hs+37−13
@@ -1,19 +1,43 @@
1+module Main where
2+
3+import Control.Monad
14import Language.Haskell.HLint3 (hlint)
5+import System.Directory
26import System.Exit (exitFailure, exitSuccess)
7+import System.FilePath.Find
8+import System.FilePath
39
410main :: IO ()
511main = do
6− ideas <- hlint
7− [ "."
8− , "--ignore=Redundant do"
9− , "--ignore=Use camelCase"
10− , "--ignore=Redundant $"
11− , "--ignore=Use &&"
12− , "--ignore=Use &&&"
13− , "--ignore=Use const"
14− , "--ignore=Use >=>"
15− , "--ignore=Use ."
16− , "--ignore=Use unless"
17− , "--cpp-define=USE_TEMPLATE_HASKELL"
18− ]
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+ , "--cpp-define=USE_TEMPLATE_HASKELL"
24+ ]
25+ recurseInto = and <$> sequence
26+ [ fileType ==? Directory
27+ , fileName /=? ".git"
28+ ]
29+ matchFile = and <$> sequence
30+ [ extension ==? ".hs"
31+ , let notElem' = liftOp notElem
32+ in filePath `notElem'` filePathExceptions pwd
33+ ]
34+ files <- find always matchFile pwd
35+ ideas <- fmap concat $ forM files $ \f -> do
36+ putStr $ "linting file " ++ drop (length pwd + 1) f ++ "... "
37+ runHlint f
1938 if null ideas then exitSuccess else exitFailure
39+
40+filePathExceptions :: FilePath -> [FilePath]
41+filePathExceptions pwd = map (pwd </>) $
42+ [ "src/Data/AppendMap.hs" -- parse error when hlint runs
43+ ]