hlint 1.9.39 → 1.9.40
raw patch · 5 files changed
+36/−24 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +2/−0
- LICENSE +1/−1
- hlint.cabal +4/−2
- src/HLint.hs +12/−12
- src/Idea.hs +17/−9
CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for HLint +1.9.40+ #293, fix the JSON format of the output 1.9.39 #287, don't incorrectly suggest newtype 1.9.38
LICENSE view
@@ -1,4 +1,4 @@-Copyright Neil Mitchell 2006-2016.+Copyright Neil Mitchell 2006-2017. All rights reserved. Redistribution and use in source and binary forms, with or without
hlint.cabal view
@@ -1,13 +1,13 @@ cabal-version: >= 1.18 build-type: Simple name: hlint-version: 1.9.39+version: 1.9.40 license: BSD3 license-file: LICENSE category: Development author: Neil Mitchell <ndmitchell@gmail.com> maintainer: Neil Mitchell <ndmitchell@gmail.com>-copyright: Neil Mitchell 2006-2016+copyright: Neil Mitchell 2006-2017 synopsis: Source code suggestions description: HLint gives suggestions on how to improve your source code.@@ -37,10 +37,12 @@ flag threaded default: True+ manual: True description: Build with support for multithreaded execution flag gpl default: True+ manual: True description: Use GPL libraries, specifically hscolour library
src/HLint.hs view
@@ -130,18 +130,18 @@ settings <- readAllSettings cmd flags ideas <- getIdeas cmd settings flags let (showideas,hideideas) = partition (\i -> cmdShowAll || ideaSeverity i /= Ignore) ideas- if cmdJson- then putStrLn . showIdeasJson $ showideas- else if cmdSerialise then do- hSetBuffering stdout NoBuffering- print $ map (show &&& ideaRefactoring) showideas- else if cmdRefactor then- handleRefactoring showideas cmdFiles cmd- else do- usecolour <- cmdUseColour cmd- showItem <- if usecolour then showANSI else return show- mapM_ (outStrLn . showItem) showideas- handleReporting showideas hideideas cmd+ if cmdJson then+ putStrLn $ showIdeasJson showideas+ else if cmdSerialise then do+ hSetBuffering stdout NoBuffering+ print $ map (show &&& ideaRefactoring) showideas+ else if cmdRefactor then+ handleRefactoring showideas cmdFiles cmd+ else do+ usecolour <- cmdUseColour cmd+ showItem <- if usecolour then showANSI else return show+ mapM_ (outStrLn . showItem) showideas+ handleReporting showideas hideideas cmd return showideas getIdeas :: Cmd -> [Setting] -> ParseFlags -> IO [Idea]
src/Idea.hs view
@@ -3,6 +3,8 @@ module Idea(module Idea, Note(..), showNotes, Severity(..)) where import Data.List.Extra+import Data.Char+import Numeric import HSE.All import Settings import HsColour@@ -26,21 +28,27 @@ showIdeaJson :: Idea -> String showIdeaJson idea@Idea{ideaSpan=srcSpan@SrcSpan{..}, ..} = wrap . intercalate "," . map mkPair $- [("module", show ideaModule)- ,("decl", show ideaDecl)- ,("severity", show . show $ ideaSeverity)- ,("hint", show ideaHint)- ,("file", show srcSpanFilename)+ [("module", str ideaModule)+ ,("decl", str ideaDecl)+ ,("severity", str $ show ideaSeverity)+ ,("hint", str ideaHint)+ ,("file", str srcSpanFilename) ,("startLine", show srcSpanStartLine) ,("startColumn", show srcSpanStartColumn) ,("endLine", show srcSpanEndLine) ,("endColumn", show srcSpanEndColumn)- ,("from", show ideaFrom)- ,("to", maybe "null" show ideaTo)- ,("note", show $ map (show . show) ideaNote)- ,("refactorings", show . show $ ideaRefactoring)+ ,("from", str ideaFrom)+ ,("to", maybe "null" str ideaTo)+ ,("note", show $ map (str . show) ideaNote)+ ,("refactorings", str $ show ideaRefactoring) ] where+ str x = "\"" ++ concatMap f x ++ "\""+ where f '\"' = "\\\""+ f '\\' = "\\\\"+ f '\n' = "\\n"+ f x | not $ isAscii x = "\\u" ++ takeEnd 4 ("0000" ++ showHex (ord x) "")+ f x = [x] mkPair (k, v) = show k ++ ":" ++ v wrap x = "{" ++ x ++ "}"