hlint 2.0.3 → 2.0.4
raw patch · 6 files changed
+26/−5 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +2/−0
- data/default.yaml +4/−0
- hlint.cabal +1/−1
- src/HLint.hs +15/−2
- src/Idea.hs +3/−0
- src/Test/All.hs +1/−2
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for HLint +2.0.4+ --default adds ignores for any warnings it finds 2.0.3 #312, suggest removing the DeriveAnyClass extension Suggest removing the DeriveLift extension
data/default.yaml view
@@ -54,3 +54,7 @@ # Define some custom infix operators # - fixity: infixr 3 ~^#^~+++# To generate a suitable file for HLint do:+# $ hlint --default > .hlint.yaml
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: hlint-version: 2.0.3+version: 2.0.4 license: BSD3 license-file: LICENSE category: Development
src/HLint.hs view
@@ -8,7 +8,7 @@ import Control.Exception import Control.Concurrent.Extra import System.Console.CmdArgs.Verbosity-import Data.List+import Data.List.Extra import GHC.Conc import System.Exit import System.IO.Extra@@ -99,10 +99,23 @@ else runGrep cmdPattern (cmdParseFlags cmd) files +withVerbosity :: Verbosity -> IO a -> IO a+withVerbosity new act = do+ old <- getVerbosity+ (setVerbosity new >> act) `finally` setVerbosity old+ hlintMain :: [String] -> Cmd -> IO [Idea] hlintMain args cmd@CmdMain{..} | cmdDefault = do- putStr =<< readFile (cmdDataDir </> "default.yaml")+ ideas <- if null cmdFiles then return [] else withVerbosity Quiet $+ runHlintMain args cmd{cmdJson=False,cmdSerialise=False,cmdRefactor=False} Nothing+ let bad = nubOrd $ map ideaHint ideas+ src <- readFile $ cmdDataDir </> "default.yaml"+ if null bad then putStr src else do+ let group1:groups = splitOn ["",""] $ lines src+ let group2 = "# Warnings currently triggered by your code" :+ ["- ignore: {name: " ++ show x ++ "}" | x <- bad]+ putStr $ unlines $ intercalate ["",""] $ group1:group2:groups return [] | null cmdFiles && not (null cmdFindHints) = do hints <- concatMapM (resolveFile cmd Nothing) cmdFindHints
src/Idea.hs view
@@ -33,6 +33,9 @@ } deriving (Eq,Ord) +-- I don't use aeson here for 2 reasons:+-- 1) Aeson doesn't esape unicode characters, and I want to (allows me to ignore encoding)+-- 2) I want to control the format so it's slightly human readable as well showIdeaJson :: Idea -> String showIdeaJson idea@Idea{ideaSpan=srcSpan@SrcSpan{..}, ..} = wrap . intercalate "," . map mkPair $ [("module", str ideaModule)
src/Test/All.hs view
@@ -67,7 +67,6 @@ checkCommentedYaml :: FilePath -> IO () checkCommentedYaml file = do src <- lines <$> readFile' file- let src2 = [x | x <- src, Just x <- [stripPrefix "# " x], not $ all isAlpha $ take 1 x]+ let src2 = [x | x <- src, Just x <- [stripPrefix "# " x], not $ all (\x -> isAlpha x || x == '$') $ take 1 x] e <- readFilesConfig [(file, Just $ unlines src2)] void $ evaluate $ length e-