1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
module Pretty.ShowOptions where

import Pretty.ToString    (renderMessagesToString)
import Pretty.ToJson      (renderMessagesToJson)
import Types

-- returns a String containing the config settings
showOptions :: Config -> String
showOptions (Config checks output verbosity hint code mLength) =
  "--------------------------------"
  ++ "\nSETTINGS:"
  ++ "\nverbosity: " ++ (showVerbosity verbosity)
  ++ "\noutput format: " ++ (show output)
  ++ "\nshow hint: " ++ (showBool hint)
  ++ "\nshow code exerpt: " ++ (showBool code)
  ++ "\nmaximal linelength: " ++ (show mLength)
  ++ "\nlist of checks: " ++ (showCheckList checks)

-- details verbosity level
showVerbosity :: Int -> String
showVerbosity 0 = "quiet, only show check warnings"
showVerbosity 1 = "default, enable showing hints and code part, segment output of each file"
showVerbosity 2 = "verbose, INFO and WARNING messages concerning progress of the tool are shown"
showVerbosity 3 = "debug, show options"

-- return on and off instead of true and false
showBool :: Bool -> String
showBool True = "on"
showBool False = "off"

-- renders checklist
showCheckList :: CheckList -> String
showCheckList (CheckList lineLength
                         tab
                         trailingS
                         whiteSpace
                         ifThenElse
                         doIndent
                         letIndent
                         caseIndent
                         guardIndent
                         rhsAlign
                         whereIndent
                         equalstrue
                         topLevelSig
                         blankLines
                         moduleheader
                         imports
                         dataIndent
                         listIndent
                         thenTrueElseFalse
                         notEqual
                         notOrd
                         equalsEmptyList
                         identFunc
                         constFunc
                         andOr
                         printCheck
                         derivingIndent
                         classIndent
                         instanceIndent
                         ) =
  "\n  general"
  ++ "\n    length exceeding lines : " ++ (showBool lineLength)
  ++ "\n    tab characters : " ++ (showBool tab)
  ++ "\n    trailing spaces : " ++ (showBool trailingS)
  ++ "\n    other whitespaces (except linebreaks) : " ++ (showBool whiteSpace)
  ++ "\n    signatures (positioning): " ++ (showBool topLevelSig)
  ++ "\n    blank lines: " ++ (showBool blankLines)
  ++ "\n  formatting"
  ++ "\n    if-then-else : " ++ (showBool ifThenElse)
  ++ "\n    do: " ++ (showBool doIndent)
  ++ "\n    let: " ++ (showBool letIndent)
  ++ "\n    case: " ++ (showBool caseIndent)
  ++ "\n    guards: " ++ (showBool guardIndent)
  ++ "\n    guards and equations in a function: " ++ (showBool rhsAlign)
  ++ "\n    where: " ++ (showBool whereIndent)
  ++ "\n    module header : " ++ (showBool moduleheader)
  ++ "\n    import declarations : " ++ (showBool imports)
  ++ "\n    data (and record) declarations: " ++ (showBool dataIndent)
  ++ "\n    list and tuple declarations: " ++ (showBool listIndent)
  ++ "\n    fold (||), (&&) : " ++ (showBool andOr)
  ++ "\n    deriving : " ++ (showBool derivingIndent)
  ++ "\n    class declarations : " ++ (showBool classIndent)
  ++ "\n    instance declarations : " ++ (showBool instanceIndent)
  ++ "\n  code linting (patterns)"
  ++ "\n    x == True: " ++ (showBool equalstrue)
  ++ "\n    if x then True (False) else False (True): " ++ (showBool thenTrueElseFalse)
  ++ "\n    not (a == b): " ++ (showBool notEqual)
  ++ "\n    not (a orderingOperation b): " ++ (showBool notOrd)
  ++ "\n    a == []: " ++ (showBool equalsEmptyList)
  ++ "\n    \\x -> x: " ++ (showBool identFunc)
  ++ "\n    \\x y -> x: " ++ (showBool constFunc)
  ++ "\n    fold (||), (&&) : " ++ (showBool andOr)
  ++ "\n    putStrLn (show a) : " ++ (showBool printCheck)