root / src / lint-hints.hs @ a861d322
History | View | Annotate | Download (1 kB)
1 | 5b11f8db | Iustin Pop | {-| Custom hint lints for Ganeti. |
---|---|---|---|
2 | 2cdaf225 | Iustin Pop | |
3 | 5b11f8db | Iustin Pop | Since passing --hint to hlint will override, not extend the built-in |
4 | 5b11f8db | Iustin Pop | hints, we need to import the existing hints so that we get full |
5 | 5b11f8db | Iustin Pop | coverage. |
6 | 2cdaf225 | Iustin Pop | |
7 | 2cdaf225 | Iustin Pop | -} |
8 | 2cdaf225 | Iustin Pop | |
9 | 5b11f8db | Iustin Pop | import "hint" HLint.HLint |
10 | 2cdaf225 | Iustin Pop | import "hint" HLint.Dollar |
11 | 2cdaf225 | Iustin Pop | |
12 | 5a1e31b4 | Iustin Pop | -- The following two hints warn to simplify e.g. "map (\v -> (v, |
13 | 5a1e31b4 | Iustin Pop | -- True)) lst" to "zip lst (repeat True)", which is more abstract |
14 | 5a1e31b4 | Iustin Pop | warn = map (\v -> (v, x)) y ==> zip y (repeat x) |
15 | 5a1e31b4 | Iustin Pop | where _ = notIn v x |
16 | 5a1e31b4 | Iustin Pop | warn = map (\v -> (x, v)) ==> zip (repeat x) |
17 | 5a1e31b4 | Iustin Pop | where _ = notIn v x |
18 | 0c76f280 | Iustin Pop | |
19 | 0c76f280 | Iustin Pop | -- The following warn on use of length instead of null |
20 | 0c76f280 | Iustin Pop | warn = length x > 0 ==> not (null x) |
21 | 0c76f280 | Iustin Pop | warn = length x /= 0 ==> not (null x) |
22 | 0c76f280 | Iustin Pop | warn = length x == 0 ==> null x |
23 | 72747d91 | Iustin Pop | |
24 | 72747d91 | Iustin Pop | -- Never use head, use 'case' which covers all possibilities |
25 | 72747d91 | Iustin Pop | warn = head x ==> case x of { y:_ -> y } where note = "Head is unsafe, please use case and handle the empty list as well" |
26 | 72747d91 | Iustin Pop | |
27 | 72747d91 | Iustin Pop | -- Never use tail, use 'case' which covers all possibilities |
28 | 72747d91 | Iustin Pop | warn = tail x ==> case x of { _:y -> y } where note = "Tail is unsafe, please use case and handle the empty list as well" |