Permalink
Browse files

Add trailingWhitespace checker

  • Loading branch information...
1 parent 29ddc8c commit 87db8c2c6247393fe4a1afe7b949155e93145053 @jaspervdj jaspervdj committed Oct 27, 2011
Showing with 9 additions and 1 deletion.
  1. +8 −0 src/HStyle.hs
  2. +1 −1 src/HStyle/Alignment.hs
View
@@ -5,6 +5,7 @@ module HStyle
) where
import Control.Monad (forM_, unless)
+import Data.Char (isSpace)
import System.Environment (getArgs)
import qualified Data.Text as T
@@ -61,6 +62,12 @@ lineLengthCheck max' = checkLines $ \line -> if T.length line > max'
then Just $ "exceeds max line length of " `T.append` T.pack (show max')
else Nothing
+trailingWhiteSpace :: Checker
+trailingWhiteSpace = checkLines $ \line ->
+ if not (T.null line) && isSpace (T.last line)
+ then Just "trailing whitespace"
+ else Nothing
+
main :: IO ()
main = do
[file] <- getArgs
@@ -71,4 +78,5 @@ main = do
runRule block md (typeSigSelector, typeSigCheck)
runRule block md (selectLines, tabsCheck)
runRule block md (selectLines, lineLengthCheck 80)
+ runRule block md (selectLines, trailingWhiteSpace)
err -> putStrLn $ show err
View
@@ -19,7 +19,7 @@ checkAlignment alignment
alignment' = filter (not . null) alignment
heads = map head alignment'
-equal :: Eq a
+equal :: Eq a
=> [a]
-> Bool
equal (x : y : r)

0 comments on commit 87db8c2

Please sign in to comment.