packages feed

hlint 1.8.4 → 1.8.5

raw patch · 9 files changed

+237/−195 lines, 9 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

data/Default.hs view
@@ -84,6 +84,9 @@ error = intercalate " " ==> unwords warn  = concat (intersperse x y) ==> intercalate x y where _ = notEq x " " warn  = concat (intersperse " " x) ==> unwords x+error "Use any" = null (filter f x) ==> not (any f x)+error "Use any" = filter f x == [] ==> not (any f x)+error = filter f x /= [] ==> any f x  -- FOLDS 
− data/report.html
@@ -1,168 +0,0 @@-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">-<head>-<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />-<title>HLint Report</title>-<script type='text/javascript'>--/* == Algorithm for show/unshow ==-   Each hint/file is given a number, hint# or file#-   When we say showOnly with a class name we add the rules to-   the css #content div {display:none}, #content div.className {display:block}-   When going back to showAll we remove these results-*/--// CSS MANIPULATION //--function deleteRules(n)-{-	var css = document.styleSheets[0];-	for (var i = 0; i < n; i++)-		css.deleteRule(css.cssRules.length-1);-}--function insertRule(s)-{-	var css = document.styleSheets[0];-	css.insertRule(s, css.cssRules.length);-}--// SHOW/HIDE LOGIC //--var last = "";--function show(id)-{-	if (id == last) return;-	if (id == "")-	{-		deleteRules(3);-		insertRule(".all {font-weight: bold;}");-	}-	else-	{-		if (last == "")-		{-			deleteRules(1);-			insertRule("#content div {display:none;}");-		}-		else-		{-			deleteRules(2);-		}-		insertRule("#content div." + id + " {display:block;}");-		insertRule("#" + id + "{font-weight:bold;}");-	}--	last = id;-}--</script>-<style type="text/css">-/* These rules are manipulated by the script.-   The commented form is how it looks with an id selected */--.all {font-weight: bold;}      /* #content div {display:none;} */-                               /* #content div.id {display:block;} */-                               /* #id {font-weight: bold;} */--</style>-<style type="text/css">-/* See http://www.webreference.com/programming/css_frames/ */-body {-	margin:0;-	border:0;-	padding:0;-	height:100%;-	max-height:100%;-	font-family: sans-serif;-	font-size:76%;-	overflow: hidden;-}--#leftbar {-	position:absolute;-	top:0px;-	left:0px;-	width: 215px;-	bottom: 0px;-	overflow:auto;-	background:rgb(202,223,255);-	margin: 10px;-	padding-top: 0;-	padding-left: 7px;-	padding-right: 7px;-	-moz-border-radius: 5px;-	-webkit-border-radius: 5px;--	display:none; /* Override if script present */-}--#content {-	position:absolute;-	top:0;-	bottom:0;-	right:0;-	overflow:auto;-	padding-bottom: 15px;-	padding-right: 7px;--	left:10px; /* Override if script present */-}--#leftbar ul {margin-top: 0px; padding-left: 15px;}-#leftbar p {margin-bottom: 0px;}--pre {-	font-family: "lucida console", monospace;-	padding-left: 15px;-	margin: 2px;-}--#content div {-	margin-bottom: 10px;-	margin-right: 10px;-	padding-top: 4px;-	border-top: 1px solid #ccc;-}--.script #content {left:250px;}-.script #leftbar {display: block;}--/* From HsColour */-.hs-keyglyph, .hs-layout {color: red;}-.hs-keyword {color: blue;}-.hs-comment, .hs-comment a {color: green;}-.hs-str, .hs-chr {color: teal;}-</style>-</head>-<body>--<script type='text/javascript'>-document.body.className = "script";-</script>--<div id="leftbar" valign="top" style="min-width:200px">--<p><a class="all" href="javascript:show('')">All hints</a></p>-<ul>-$HINTS-</ul>--<p><a class="all" href="javascript:show('')">All files</a></p>-<ul>-$FILES-</ul>--</div>-<div id="content" valign="top" width="100%">-<p>-	Report generated by <a href="http://community.haskell.org/~ndm/hlint/">HLint</a>-$VERSION-	- a tool to suggest improvements to your Haskell code.-</p>--$CONTENT-</div>-</body>-</html>
+ data/report_template.html view
@@ -0,0 +1,168 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">+<head>+<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />+<title>HLint Report</title>+<script type='text/javascript'>++/* == Algorithm for show/unshow ==+   Each hint/file is given a number, hint# or file#+   When we say showOnly with a class name we add the rules to+   the css #content div {display:none}, #content div.className {display:block}+   When going back to showAll we remove these results+*/++// CSS MANIPULATION //++function deleteRules(n)+{+	var css = document.styleSheets[0];+	for (var i = 0; i < n; i++)+		css.deleteRule(css.cssRules.length-1);+}++function insertRule(s)+{+	var css = document.styleSheets[0];+	css.insertRule(s, css.cssRules.length);+}++// SHOW/HIDE LOGIC //++var last = "";++function show(id)+{+	if (id == last) return;+	if (id == "")+	{+		deleteRules(3);+		insertRule(".all {font-weight: bold;}");+	}+	else+	{+		if (last == "")+		{+			deleteRules(1);+			insertRule("#content div {display:none;}");+		}+		else+		{+			deleteRules(2);+		}+		insertRule("#content div." + id + " {display:block;}");+		insertRule("#" + id + "{font-weight:bold;}");+	}++	last = id;+}++</script>+<style type="text/css">+/* These rules are manipulated by the script.+   The commented form is how it looks with an id selected */++.all {font-weight: bold;}      /* #content div {display:none;} */+                               /* #content div.id {display:block;} */+                               /* #id {font-weight: bold;} */++</style>+<style type="text/css">+/* See http://www.webreference.com/programming/css_frames/ */+body {+	margin:0;+	border:0;+	padding:0;+	height:100%;+	max-height:100%;+	font-family: sans-serif;+	font-size:76%;+	overflow: hidden;+}++#leftbar {+	position:absolute;+	top:0px;+	left:0px;+	width: 215px;+	bottom: 0px;+	overflow:auto;+	background:rgb(202,223,255);+	margin: 10px;+	padding-top: 0;+	padding-left: 7px;+	padding-right: 7px;+	-moz-border-radius: 5px;+	-webkit-border-radius: 5px;++	display:none; /* Override if script present */+}++#content {+	position:absolute;+	top:0;+	bottom:0;+	right:0;+	overflow:auto;+	padding-bottom: 15px;+	padding-right: 7px;++	left:10px; /* Override if script present */+}++#leftbar ul {margin-top: 0px; padding-left: 15px;}+#leftbar p {margin-bottom: 0px;}++pre {+	font-family: "lucida console", monospace;+	padding-left: 15px;+	margin: 2px;+}++#content div {+	margin-bottom: 10px;+	margin-right: 10px;+	padding-top: 4px;+	border-top: 1px solid #ccc;+}++.script #content {left:250px;}+.script #leftbar {display: block;}++/* From HsColour */+.hs-keyglyph, .hs-layout {color: red;}+.hs-keyword {color: blue;}+.hs-comment, .hs-comment a {color: green;}+.hs-str, .hs-chr {color: teal;}+</style>+</head>+<body>++<script type='text/javascript'>+document.body.className = "script";+</script>++<div id="leftbar" valign="top" style="min-width:200px">++<p><a class="all" href="javascript:show('')">All hints</a></p>+<ul>+$HINTS+</ul>++<p><a class="all" href="javascript:show('')">All files</a></p>+<ul>+$FILES+</ul>++</div>+<div id="content" valign="top" width="100%">+<p>+	Report generated by <a href="http://community.haskell.org/~ndm/hlint/">HLint</a>+$VERSION+	- a tool to suggest improvements to your Haskell code.+</p>++$CONTENT+</div>+</body>+</html>
hlint.cabal view
@@ -1,14 +1,14 @@ cabal-version:      >= 1.6 build-type:         Simple name:               hlint-version:            1.8.4+version:            1.8.5 -- license is GPL v2 only license:            GPL license-file:       LICENSE category:           Development author:             Neil Mitchell <ndmitchell@gmail.com> maintainer:         Neil Mitchell <ndmitchell@gmail.com>-copyright:          Neil Mitchell 2006-2010+copyright:          Neil Mitchell 2006-2011 synopsis:           Source code suggestions description:     HLint gives suggestions on how to improve your source code.@@ -21,7 +21,7 @@     Dollar.hs     HLint.hs     Test.hs-    report.html+    report_template.html     hs-lint.el     hlint.1     hlint.ghci
src/CmdLine.hs view
@@ -35,7 +35,7 @@     ,cmdColor :: Bool                -- ^ color the result     ,cmdCpp :: CppFlags              -- ^ options for CPP     ,cmdDataDir :: FilePath          -- ^ the data directory-    ,cmdEncoding :: String           -- ^ the text encoding+    ,cmdEncoding :: Encoding           -- ^ the text encoding     ,cmdFindHints :: [FilePath]      -- ^ source files to look for hints in     ,cmdLanguage :: [Extension]      -- ^ the extensions (may be prefixed by "No")     ,cmdQuiet :: Bool                -- ^ supress all console output@@ -120,8 +120,7 @@             | CPP `elem` languages = Cpphs cpphs             | otherwise = NoCpp -    let encoding = last $ "" : [x | Encoding x <- opt]-    when (encoding /= "") $ warnEncoding encoding+    encoding <- newEncoding $ last $ "" : [x | Encoding x <- opt]      return Cmd         {cmdTest = test@@ -148,7 +147,7 @@   versionText :: String-versionText = "HLint v" ++ showVersion version ++ ", (C) Neil Mitchell 2006-2010\n"+versionText = "HLint v" ++ showVersion version ++ ", (C) Neil Mitchell 2006-2011\n"   helpText :: String
src/HSE/All.hs view
@@ -24,12 +24,12 @@ data ParseFlags = ParseFlags     {cppFlags :: CppFlags     ,language :: [Extension]-    ,encoding :: String+    ,encoding :: Encoding     ,infixes :: [Fixity]     }  parseFlags :: ParseFlags-parseFlags = ParseFlags NoCpp defaultExtensions "" []+parseFlags = ParseFlags NoCpp defaultExtensions defaultEncoding []  parseFlagsNoLocations :: ParseFlags -> ParseFlags parseFlagsNoLocations x = x{cppFlags = case cppFlags x of Cpphs y -> Cpphs $ f y; y -> y}
src/Main.hs view
@@ -1,6 +1,6 @@ {- HLint, Haskell source code suggestions-Copyright (C) 2006-2010, Neil Mitchell+Copyright (C) 2006-2011, Neil Mitchell  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
src/Report.hs view
@@ -15,7 +15,7 @@  writeTemplate :: FilePath -> [(String,[String])] -> FilePath -> IO () writeTemplate dataDir content to = do-    src <- readFile $ dataDir </> "report.html"+    src <- readFile $ dataDir </> "report_template.html"     writeFile to $ unlines $ concatMap f $ lines src     where         f ('$':xs) = fromMaybe ['$':xs] $ lookup xs content
src/Util.hs view
@@ -1,10 +1,11 @@-{-# LANGUAGE CPP, ExistentialQuantification, Rank2Types #-}+{-# LANGUAGE CPP, ExistentialQuantification, Rank2Types, PatternGuards #-}  module Util where  import Control.Arrow import Control.Monad import Control.Monad.Trans.State+import Control.Exception import Data.Char import Data.Function import Data.List@@ -118,23 +119,62 @@ --------------------------------------------------------------------- -- SYSTEM.IO -readFileEncoding :: String -> FilePath -> IO String-#if __GLASGOW_HASKELL__ < 612-readFileEncoding _ = readFile-#else-readFileEncoding "" = readFile-readFileEncoding enc = \file -> do-    h <- openFile file ReadMode-    enc <- mkTextEncoding enc-    hSetEncoding h enc-    hGetContents h-#endif+-- | An encoding is a function to change a handle to a particular encoding+data Encoding = Encoding_Internal (Maybe (Handle -> IO ())) -warnEncoding :: String -> IO ()-#if __GLASGOW_HASKELL__ < 612-warnEncoding enc | enc /= "" = putStrLn "Warning: Text encodings are not supported with HLint compiled by GHC 6.10"+defaultEncoding :: Encoding+defaultEncoding = Encoding_Internal Nothing+++readFileEncoding :: Encoding -> FilePath -> IO String+readFileEncoding (Encoding_Internal x) = case x of+    Nothing -> readFile+    Just set -> \file -> do+        h <- openFile file ReadMode+        set h+        hGetContents h+++-- GHC's mkTextEncoding function is fairly poor - it doesn't support lots of fun things,+-- so we fake them up, and then try mkTextEncoding last+newEncoding :: String -> IO Encoding+newEncoding "" = return defaultEncoding+#if __GLASGOW_HASKELL__ >= 612+newEncoding enc+        | Just e <- lookup (f enc) [(f a, b) | (as,b) <- encs, a <- as] = return $ wrap e+        | otherwise = do+            res <- try $ mkTextEncoding enc :: IO (Either SomeException TextEncoding)+            case res of+                Right e -> return $ wrap e+                Left _ -> do+                    let (a,b) = splitAt 2 $ map (head . fst) encs+                    putStr $ unlines+                        ["Error: Unknown text encoding argument, " ++ enc+                        ,"Possible values:"+                        ,"  " ++ unwords a+                        ,"  " ++ unwords b+                        ,"  and anything accepted by System.IO.mkTextEncoding"]+                    exitWith $ ExitFailure 1+    where+        f = map toLower . filter (`notElem` "-_ ")+        wrap = Encoding_Internal . Just . flip hSetEncoding ++        encs = let a*b = (words a, b)+               in ["ISO8859-1 8859-1 ISO8859 8859 LATIN LATIN1" * latin1+                  ,"LOCALE" * localeEncoding+                  ,"UTF-8" * utf8+                  ,"UTF-8BOM" * utf8_bom+                  ,"UTF-16" * utf16+                  ,"UTF-16LE" * utf16le+                  ,"UTF-16BE" * utf16be+                  ,"UTF-32" * utf16+                  ,"UTF-32LE" * utf16le+                  ,"UTF-32BE" * utf16be]+#else+newEncoding enc = do+    putStrLn "Warning: Text encodings are not supported with HLint compiled by GHC 6.10"+    return defaultEncoding #endif-warnEncoding _ = return ()   exitMessage :: String -> a