forked from ArdanaLabs/ardana-dollar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.hlint.yaml
174 lines (154 loc) · 8.76 KB
/
.hlint.yaml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#####################################################################################
# #
# Settings borrowed from HLint --default #
# #
#####################################################################################
- arguments: [--color, --cpp-simple, -XQuasiQuotes]
- group: {name: generalise, enabled: true}
#####################################################################################
# #
# Settings from MLabs styleguide #
# #
#####################################################################################
#
# Changes:
# - Do not ignore "Use newtype instead of data"
#
#####################################################################################
- ignore: {name: "Use <$>"}
- warn: {name: Use explicit module import list}
- warn: {name: Use module export list}
#####################################################################################
# #
# Settings borrowed from https://github.com/NorfairKing/haskell-dangerous-functions #
# #
#####################################################################################
#
# Changes:
# - Do not prohibit use of `return`
# - Do not prohibit use of `DeriveAnyClass` extension (required by PAB anyway)
# - Do not prohibit use of Lens library
# - Print more meaningful warning messages for `foldl`, `nub`, `read`, `decodeUtf8`,
# `either`, and `unless`
# - Prohibit use of PlutusTx's versions of `div`, `mod`, `rem`, and `quot`
#
#####################################################################################
- ignore: { name: "Use unless" }
- functions:
- {name: unsafeDupablePerformIO, within: []} # Unsafe
- {name: unsafeInterleaveIO, within: []} # Unsafe
- {name: unsafeFixIO, within: []} # Unsafe
- {name: unsafePerformIO, within: []} # Unsafe
# _VERY_ hard to get right, use the async library instead.
# See also https://github.com/informatikr/hedis/issues/165
- {name: forkIO, within: []}
# Mostly impossible to get right, rethink what you're doing entirely.
# See also https://www.reddit.com/r/haskell/comments/jsap9r/how_dangerous_is_forkprocess/
- {name: forkProcess, within: []}
- {name: undefined, within: []} # Purposely fails. Deal with errors appropriately instead.
- {name: throw, within: []} # Don't throw from pure code, use throwIO instead.
- {name: Prelude.error, within: []}
- {name: Data.List.tail, within: [], message: "partial function"}
- {name: Data.List.init, within: [], message: "partial function"}
- {name: Data.List.last, within: [], message: "partial function"}
- {name: 'Data.List.!!', within: [], message: "partial function"}
- {name: Data.List.genericIndex, within: [], message: "partial function"}
- {name: Prelude.tail, within: [], message: "partial function"}
- {name: Prelude.init, within: [], message: "partial function"}
- {name: Prelude.last, within: [], message: "partial function"}
- {name: 'Prelude.!!', within: [], message: "partial function"}
- {name: minimum, within: [], message: "partial function"}
- {name: minimumBy, within: [], message: "partial function"}
- {name: maximum, within: [], message: "partial function"}
- {name: maximumBy, within: [], message: "partial function"}
- {name: GHC.Enum.pred, within: [], message: "partial function"}
- {name: GHC.Enum.succ, within: [], message: "partial function"}
- {name: GHC.Enum.toEnum, within: [], message: "partial function"}
- {name: GHC.Enum.fromEnum, within: []} # Does not do what you think it does.
- {name: GHC.Enum.enumFrom, within: []} # Does not do what you think it does, depending on the type.
- {name: GHC.Enum.enumFromThen, within: []} # Does not do what you think it does, depending on the type.
- {name: GHC.Enum.enumFromTo, within: []} # Does not do what you think it does, depending on the type.
- {name: GHC.Enum.enumFromThenTo, within: []} # Does not do what you think it does, depending on the type.
- {name: Prelude.pred, within: [], message: "partial function"}
- {name: Prelude.succ, within: [], message: "partial function"}
- {name: Prelude.toEnum, within: [], message: "partial function"}
- {name: Prelude.fromEnum, within: []} # Does not do what you think it does.
- {name: Prelude.enumFrom, within: []} # Does not do what you think it does, depending on the type.
- {name: Prelude.enumFromThen, within: []} # Does not do what you think it does, depending on the type.
- {name: Prelude.enumFromTo, within: []} # Does not do what you think it does, depending on the type.
- {name: Prelude.enumFromThenTo, within: []} # Does not do what you think it does, depending on the type.
- {name: either, within: [], message: "confusing; just use a case-match."}
- {name: sum, within: [], message: "lazy accumulator"}
- {name: product, within: [], message: "lazy accumulator"}
# Functions involving division
- {name: Prelude.quot, within: [], message: "partial function"} # see https://github.com/NorfairKing/haskell-WAT#num-int
- {name: PlutusTx.Prelude.quotient, within: [], message: "partial function"}
- {name: Prelude.div, within: [], message: "partial function"}
- {name: PlutusTx.Prelude.divide, within: [], message: "partial function"}
- {name: Prelude.rem, within: [], message: "partial function"}
- {name: PlutusTx.Prelude.remainder, within: [], message: "partial function"}
- {name: Prelude.mod, within: [], message: "partial function"}
- {name: PlutusTx.Prelude.modulo, within: [], message: "partial function"}
- {name: Prelude.quotRem, within: [], message: "partial function"}
- {name: Prelude.divMod, within: [], message: "partial function"}
# Does unexpected things, see
# https://github.com/NorfairKing/haskell-WAT#real-double
- {name: realToFrac, within: []}
# Don't use string for command-line output.
- {name: System.IO.putChar, within: []}
- {name: System.IO.putStr, within: []}
- {name: System.IO.putStrLn, within: []}
- {name: System.IO.print, within: []}
- {name: Prelude.putChar, within: []}
- {name: Prelude.putStr, within: []}
- {name: Prelude.putStrLn, within: []}
- {name: Prelude.print, within: []}
# Don't use string for command-line input either.
- {name: System.IO.getChar, within: []}
- {name: System.IO.getLine, within: []}
- {name: System.IO.getContents, within: []} # Does lazy IO.
- {name: System.IO.interact, within: []}
- {name: System.IO.readIO, within: []}
- {name: System.IO.readLn, within: []}
- {name: Prelude.getChar, within: []}
- {name: Prelude.getLine, within: []}
- {name: Prelude.getContents, within: []} # Does lazy IO.
- {name: Prelude.interact, within: []}
- {name: Prelude.readIO, within: []}
- {name: Prelude.readLn, within: []}
# Don't use strings to interact with files
- {name: System.IO.readFile, within: []}
- {name: System.IO.writeFile, within: []}
- {name: System.IO.appendFile, within: []}
- {name: Prelude.readFile, within: []}
- {name: Prelude.writeFile, within: []}
- {name: Prelude.appendFile, within: []}
# Can succeed in dev, but fail in prod, because of encoding guessing
# It's also Lazy IO.
# See https://www.snoyman.com/blog/2016/12/beware-of-readfile/ for more info.
- {name: Data.Text.IO.readFile, within: [], message: "introduces encoding errors"}
- {name: Data.Text.IO.Lazy.readFile, within: [], message: "introduces encoding errors"}
- {name: fromJust, within: [], message: "partial function"}
# Does silent truncation:
# > fromIntegral (300 :: Word) :: Word8
# 44
- {name: fromIntegral, within: []}
- extensions:
- { name: NamedFieldPuns, within: [] }
- { name: OverloadedLabels, within: [] }
# Better error messages
- warn: {name: "Avoid lazy foldl", lhs: foldl, rhs: foldl', note: "lazy; use foldl' instead"}
- warn: {name: "Avoid partial read", lhs: read, rhs: Text.Read.readMaybe, note: "partial function"}
- warn: {name: "Avoid unless", lhs: unless, rhs: when . not, note: "confusing"}
- warn: {name: "Avoid head", lhs: Data.List.head, rhs: listToMaybe, note: "partial function"}
- warn: {name: "Avoid head", lhs: Prelude.head, rhs: listToMaybe, note: "partial function"}
- warn:
name: "Avoid using nub because of time complexity"
lhs: nub
rhs: Data.Containers.ListUtils.nubOrd
note: "O(n^2)"
- warn:
name: "Avoid throwing decode"
lhs: Data.Text.Encoding.decodeUtf8
rhs: Data.Text.Encoding.decodeUtf8'
note: "throws on invalid UTF-8 data"