on develop help sign in
change the way we invoke hlint to be more flexible at the file level
ef4da28Dan Haraj
default.nix+2−2
@@ -4,7 +4,7 @@
4, monad-control, mtl, primitive, ref-tf, semigroupoids
4, monad-control, mtl, primitive, ref-tf, semigroupoids
5, semigroups, split, stdenv, stm, syb, template-haskell
5, semigroups, split, stdenv, stm, syb, template-haskell
6, these, transformers, transformers-compat, prim-uniq
6, these, transformers, transformers-compat, prim-uniq
7−, data-default
7+, data-default, filepath, directory, filemanip
8, useTemplateHaskell ? true
8, useTemplateHaskell ? true
9}:
9}:
10mkDerivation {
10mkDerivation {
@@ -23,7 +23,7 @@ mkDerivation {
23 haskell-src-exts haskell-src-meta
23 haskell-src-exts haskell-src-meta
24 ]);
24 ]);
25 testHaskellDepends = if ghc.isGhcjs or false then [] else [
25 testHaskellDepends = if ghc.isGhcjs or false then [] else [
26− hlint
26+ hlint filepath directory filemanip
27 ];
27 ];
28 configureFlags = if useTemplateHaskell then [] else [
28 configureFlags = if useTemplateHaskell then [] else [
29 "-f-use-template-haskell"
29 "-f-use-template-haskell"
reflex.cabal+5−1
@@ -175,7 +175,11 @@ test-suite hlint
175 type: exitcode-stdio-1.0
175 type: exitcode-stdio-1.0
176 main-is: hlint.hs
176 main-is: hlint.hs
177 hs-source-dirs: test
177 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.*
179 if impl(ghcjs)
183 if impl(ghcjs)
180 buildable: False
184 buildable: False
181
185
test/hlint.hs+37−13
@@ -1,19 +1,43 @@
1+module Main where
2+
3+import Control.Monad
1import Language.Haskell.HLint3 (hlint)
4import Language.Haskell.HLint3 (hlint)
5+import System.Directory
2import System.Exit (exitFailure, exitSuccess)
6import System.Exit (exitFailure, exitSuccess)
7+import System.FilePath.Find
8+import System.FilePath
3
9
4main :: IO ()
10main :: IO ()
5main = do
11main = do
6− ideas <- hlint
12+ pwd <- getCurrentDirectory
7− [ "."
13+ let runHlint f = hlint $ f:
8− , "--ignore=Redundant do"
14+ [ "--ignore=Redundant do"
9− , "--ignore=Use camelCase"
15+ , "--ignore=Use camelCase"
10− , "--ignore=Redundant $"
16+ , "--ignore=Redundant $"
11− , "--ignore=Use &&"
17+ , "--ignore=Use &&"
12− , "--ignore=Use &&&"
18+ , "--ignore=Use &&&"
13− , "--ignore=Use const"
19+ , "--ignore=Use const"
14− , "--ignore=Use >=>"
20+ , "--ignore=Use >=>"
15− , "--ignore=Use ."
21+ , "--ignore=Use ."
16− , "--ignore=Use unless"
22+ , "--ignore=Use unless"
17− , "--cpp-define=USE_TEMPLATE_HASKELL"
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
18− ]
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
19 if null ideas then exitSuccess else exitFailure
38 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+ ]