Skip to content

Commit eb7062c

Browse files
ulysses4everandreasabel
authored andcommitted
address code review
1 parent 60658a1 commit eb7062c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

FixWhitespace.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ fix mode verbose tabSize f =
223223
hPutStrLn stderr $
224224
"[ Violation " ++
225225
(if mode == Fix then "fixed" else "detected") ++
226-
" ] " ++ f ++ ":\n" ++ (unlines $ map displayViolations vs)
226+
" ] " ++ f ++
227+
(if mode == Fix then "" else
228+
":\n" ++ (unlines $ map (displayViolations f) vs))
227229

228230
when (mode == Fix) $
229231
withFile f WriteMode $ \h -> do
@@ -240,8 +242,8 @@ fix mode verbose tabSize f =
240242
-- Stores the index of the line and the line itself.
241243
data LineViolating = LV Int Text
242244

243-
displayViolations :: LineViolating -> String
244-
displayViolations (LV i l) = "line " ++ show i ++ "] " ++
245+
displayViolations :: FilePath -> LineViolating -> String
246+
displayViolations fname (LV i l) = fname ++ ":" ++ show i ++ ": " ++
245247
(Text.unpack $ visibleSpaces l)
246248

247249
-- | The transformation monad: maintains info about lines that
@@ -331,5 +333,5 @@ dropWhile1 p (x:xs)
331333
-- presentation purposes. Space turns into '·' and tab into '→'
332334
visibleSpaces :: Text -> Text
333335
visibleSpaces s
334-
| Text.null s = "<empty line>"
335-
| otherwise = Text.replace "\t" "" . Text.replace " " "·" $ s
336+
| Text.null s = "<NEWLINE>"
337+
| otherwise = Text.replace "\t" "<TAB>" . Text.replace " " "·" $ s

0 commit comments

Comments
 (0)