Skip to content

Commit 772014d

Browse files
committed
Warn on use of unsafe decodeUtf8
1 parent 02966a1 commit 772014d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

data/hlint.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
- import Data.Attoparsec.Text
5252
- import Data.Attoparsec.ByteString
5353

54+
- package:
55+
name: text
56+
modules:
57+
- import Data.Text
58+
- import Data.Text.Encoding
59+
5460
- package:
5561
name: codeworld-api
5662
modules:
@@ -869,6 +875,14 @@
869875
- warn: {lhs: Data.Attoparsec.Text.option Nothing (Just <$> p), rhs: optional p}
870876
- warn: {lhs: Data.Attoparsec.ByteString.option Nothing (Just <$> p), rhs: optional p}
871877

878+
- group:
879+
name: text
880+
enabled: true
881+
imports:
882+
- package text
883+
rules:
884+
- warn: {lhs: decodeUtf8, rhs: decodeUtf8', name: Avoid decodeUtf8}
885+
872886
- group:
873887
name: generalise
874888
enabled: false
@@ -1235,6 +1249,10 @@
12351249
# issue1183 = (a >= 'a') && (a <= 'z') -- isAsciiLower a
12361250
# issue1218 = uncurry (zipWith g) $ (a, b) -- zipWith g a b
12371251

1252+
# import Data.Text
1253+
# import Data.Text.Encoding
1254+
# yes = decodeUtf8 -- decodeUtf8'
1255+
12381256
# import Language.Haskell.TH\
12391257
# yes = varE 'foo -- [|foo|]
12401258
# import Prelude \

hints.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11921,4 +11921,20 @@ optional p
1192111921
</td>
1192211922
<td>Warning</td>
1192311923
</tr>
11924+
<tr>
11925+
<td>Avoid decodeUtf8</td>
11926+
<td>
11927+
LHS:
11928+
<code>
11929+
Data.Text.Encoding.decodeUtf8
11930+
</code>
11931+
<br>
11932+
RHS:
11933+
<code>
11934+
Data.Text.Encoding.decodeUtf8'
11935+
</code>
11936+
<br>
11937+
</td>
11938+
<td>Warning</td>
11939+
</tr>
1192411940
</table>

0 commit comments

Comments
 (0)