@@ -25,14 +25,31 @@ main = do
25
25
settings <- readSettings cmdHintFiles
26
26
let apply = map (classify settings) . applyHint (readHints settings)
27
27
ideas <- liftM concat $ mapM (liftM apply . parseFile) cmdFiles
28
- mapM_ print [i | i <- ideas, rank i /= Skip ]
29
-
30
- let n = length ideas
31
- if n == 0 then do
28
+ mapM_ print [i | i <- ideas, cmdShowSkip || rank i /= Skip ]
29
+
30
+ -- figure out statistics
31
+ let counts = map (head &&& length ) $ group $ sort $ map rank ideas
32
+ let [skip,warn,fix] = map (fromMaybe 0 . flip lookup counts) [Skip ,Warn ,Fix ]
33
+ let total = skip + warn + fix
34
+ let shown = if cmdShowSkip then total else total- skip
35
+ let skipped = total- shown
36
+
37
+ if shown == 0 then do
32
38
when (cmdReports /= [] ) $ putStrLn " Skipping writing reports"
33
- putStrLn " No relevant suggestions"
39
+ printMsg " No relevant suggestions" [(skipped, " skipped " )]
34
40
else do
35
41
flip mapM_ cmdReports $ \ x -> do
36
42
putStrLn $ " Writing report to " ++ x ++ " ..."
37
43
writeReport x ideas
38
- putStrLn $ " Found " ++ show n ++ " suggestions"
44
+ printMsg (" Found " ++ show shown ++ " suggestion" ++ [' s' | shown/= 1 ])
45
+ [(fix," serious" ),(skipped," skipped" )]
46
+
47
+
48
+ printMsg :: String -> [(Int , String )] -> IO ()
49
+ printMsg msg extras =
50
+ putStrLn $ msg ++ if null xs then " " else
51
+ " (" ++ intercalate " , " xs ++ " )"
52
+ where
53
+ xs = concatMap f extras
54
+ f (0 ,_) = []
55
+ f (i,x) = [unwords [show i, if i == 1 then " was" else " were" , x]]
0 commit comments