hlint 2.0.1 → 2.0.2
raw patch · 8 files changed
+45/−22 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +5/−0
- data/default.yaml +2/−2
- data/hlint.yaml +15/−15
- hlint.cabal +1/−1
- src/Config/Type.hs +1/−1
- src/Idea.hs +3/−2
- src/Report.hs +6/−1
- src/Test/All.hs +12/−0
CHANGES.txt view
@@ -1,5 +1,10 @@ Changelog for HLint +2.0.2+ #323, try and avoid malformatted JSON+ #324, use `backticks` in notes+ #324, remove double escaping in note for --json+ #322, fix the YAML syntax in default.yaml 2.0.1 #320, still read ./HLint.hs if it exists 2.0
data/default.yaml view
@@ -15,7 +15,7 @@ # # - extensions: # - default: false # all extension are banned by default-# - name: PatternGuards, ViewPatterns # only these listed extensions can be used+# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used # - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module # # - flags:@@ -32,7 +32,7 @@ # Add custom hints for this project # # Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"-# - error: {lhs: wibbleMany [x], rhs: wibbleOne x}+# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x} # Turn on hints that are off by default
data/hlint.yaml view
@@ -150,12 +150,12 @@ - warn: {lhs: "filter f x /= []", rhs: any f x} - warn: {lhs: any id, rhs: or} - warn: {lhs: all id, rhs: and}- - warn: {lhs: any ((==) a), rhs: elem a, note: ValidInstance "Eq" a}+ - warn: {lhs: any ((==) a), rhs: elem a, note: ValidInstance Eq a} - warn: {lhs: any (== a), rhs: elem a}- - warn: {lhs: any (a ==), rhs: elem a, note: ValidInstance "Eq" a}- - warn: {lhs: all ((/=) a), rhs: notElem a, note: ValidInstance "Eq" a}- - warn: {lhs: all (/= a), rhs: notElem a, note: ValidInstance "Eq" a}- - warn: {lhs: all (a /=), rhs: notElem a, note: ValidInstance "Eq" a}+ - warn: {lhs: any (a ==), rhs: elem a, note: ValidInstance Eq a}+ - warn: {lhs: all ((/=) a), rhs: notElem a, note: ValidInstance Eq a}+ - warn: {lhs: all (/= a), rhs: notElem a, note: ValidInstance Eq a}+ - warn: {lhs: all (a /=), rhs: notElem a, note: ValidInstance Eq a} - warn: {lhs: elem True, rhs: or} - warn: {lhs: notElem False, rhs: and} - warn: {lhs: findIndex ((==) a), rhs: elemIndex a}@@ -165,8 +165,8 @@ - warn: {lhs: findIndices (a ==), rhs: elemIndices a} - warn: {lhs: findIndices (== a), rhs: elemIndices a} - warn: {lhs: "lookup b (zip l [0..])", rhs: elemIndex b l}- - hint: {lhs: "elem x [y]", rhs: x == y, note: ValidInstance "Eq" a}- - hint: {lhs: "notElem x [y]", rhs: x /= y, note: ValidInstance "Eq" a}+ - hint: {lhs: "elem x [y]", rhs: x == y, note: ValidInstance Eq a}+ - hint: {lhs: "notElem x [y]", rhs: x /= y, note: ValidInstance Eq a} - hint: {lhs: length x >= 0, rhs: "True", name: Length always non-negative} - hint: {lhs: length x > 0, rhs: not (null x), note: IncreasesLaziness, name: Use null} - hint: {lhs: length x >= 1, rhs: not (null x), note: IncreasesLaziness, name: Use null}@@ -203,20 +203,20 @@ - warn: {lhs: foldr (>>) (return ()), rhs: sequence_} - warn: {lhs: foldr (&&) True, rhs: and} - warn: {lhs: foldl (&&) True, rhs: and, note: IncreasesLaziness}- - warn: {lhs: foldr1 (&&) , rhs: and, note: "RemovesError on []"}- - warn: {lhs: foldl1 (&&) , rhs: and, note: "RemovesError on []"}+ - warn: {lhs: foldr1 (&&) , rhs: and, note: "RemovesError on `[]`"}+ - warn: {lhs: foldl1 (&&) , rhs: and, note: "RemovesError on `[]`"} - warn: {lhs: foldr (||) False, rhs: or} - warn: {lhs: foldl (||) False, rhs: or, note: IncreasesLaziness}- - warn: {lhs: foldr1 (||) , rhs: or, note: "RemovesError on []"}- - warn: {lhs: foldl1 (||) , rhs: or, note: "RemovesError on []"}+ - warn: {lhs: foldr1 (||) , rhs: or, note: "RemovesError on `[]`"}+ - warn: {lhs: foldl1 (||) , rhs: or, note: "RemovesError on `[]`"} - warn: {lhs: foldl (+) 0, rhs: sum} - warn: {lhs: foldr (+) 0, rhs: sum}- - warn: {lhs: foldl1 (+) , rhs: sum, note: "RemovesError on []"}- - warn: {lhs: foldr1 (+) , rhs: sum, note: "RemovesError on []"}+ - warn: {lhs: foldl1 (+) , rhs: sum, note: "RemovesError on `[]`"}+ - warn: {lhs: foldr1 (+) , rhs: sum, note: "RemovesError on `[]`"} - warn: {lhs: foldl (*) 1, rhs: product} - warn: {lhs: foldr (*) 1, rhs: product}- - warn: {lhs: foldl1 (*) , rhs: product, note: "RemovesError on []"}- - warn: {lhs: foldr1 (*) , rhs: product, note: "RemovesError on []"}+ - warn: {lhs: foldl1 (*) , rhs: product, note: "RemovesError on `[]`"}+ - warn: {lhs: foldr1 (*) , rhs: product, note: "RemovesError on `[]`"} - warn: {lhs: foldl1 max , rhs: maximum} - warn: {lhs: foldr1 max , rhs: maximum} - warn: {lhs: foldl1 min , rhs: minimum}
hlint.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: hlint-version: 2.0.1+version: 2.0.2 license: BSD3 license-file: LICENSE category: Development
src/Config/Type.hs view
@@ -64,7 +64,7 @@ show IncreasesLaziness = "increases laziness" show DecreasesLaziness = "decreases laziness" show (RemovesError x) = "removes error " ++ x- show (ValidInstance x y) = "requires a valid " ++ x ++ " instance for " ++ y+ show (ValidInstance x y) = "requires a valid `" ++ x ++ "` instance for `" ++ y ++ "`" show (Note x) = x
src/Idea.hs view
@@ -46,7 +46,7 @@ ,("endColumn", show srcSpanEndColumn) ,("from", str ideaFrom) ,("to", maybe "null" str ideaTo)- ,("note", show $ map (str . show) ideaNote)+ ,("note", "[" ++ intercalate "," (map (str . show) ideaNote) ++ "]") ,("refactorings", str $ show ideaRefactoring) ] where@@ -54,7 +54,8 @@ where f '\"' = "\\\"" f '\\' = "\\\\" f '\n' = "\\n"- f x | not $ isAscii x = "\\u" ++ takeEnd 4 ("0000" ++ showHex (ord x) "")+ f '\r' = "\\r"+ f x | isControl x || not (isAscii x) = "\\u" ++ takeEnd 4 ("0000" ++ showHex (ord x) "") f x = [x] mkPair (k, v) = show k ++ ":" ++ v wrap x = "{" ++ x ++ "}"
src/Report.hs view
@@ -57,10 +57,15 @@ Just to -> ["Why not" ++ (if to == "" then " remove it." else "") ++ "<br/>" ,hsColourHTML to]) ++- [let n = showNotes ideaNote in if n /= "" then "<span class='note'>Note: " ++ n ++ "</span>" else ""+ [let n = showNotes ideaNote in if n /= "" then "<span class='note'>Note: " ++ writeNote n ++ "</span>" else "" ,"</div>" ,""] +-- Unescaped, but may have `backticks` for code+writeNote :: String -> String+writeNote = f . splitOn "`"+ where f (a:b:c) = escapeHTML a ++ "<tt>" ++ escapeHTML b ++ "</tt>" ++ f c+ f xs = concatMap escapeHTML xs escapeHTML :: String -> String escapeHTML = concatMap f
src/Test/All.hs view
@@ -3,10 +3,13 @@ module Test.All(test) where +import Control.Exception import Control.Monad+import Data.Char import Data.List import System.Directory import System.FilePath+import Data.Functor import Prelude import Config.Type@@ -35,6 +38,7 @@ let wrap msg act = putStr (msg ++ " ") >> act >> putStrLn "" putStrLn "Testing"+ checkCommentedYaml $ dataDir </> "default.yaml" config <- readFilesConfig [(".hlint.yaml",Nothing)] when useSrc $ wrap "Source annotations" $ forM_ builtinHints $ \(name,_) -> do@@ -59,3 +63,11 @@ testNames hints = sequence_ [ failed ["No name for the hint " ++ prettyPrint hintRuleLHS ++ " ==> " ++ prettyPrint hintRuleRHS] | SettingMatchExp x@HintRule{..} <- hints, hintRuleName == defaultHintName]++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]+ e <- readFilesConfig [(file, Just $ unlines src2)]+ void $ evaluate $ length e+