Statistics
| Branch: | Tag: | Revision:

root / src / lint-hints.hs @ 4b49a72b

History | View | Annotate | Download (1 kB)

1
{-| Custom hint lints for Ganeti.
2

    
3
Since passing --hint to hlint will override, not extend the built-in
4
hints, we need to import the existing hints so that we get full
5
coverage.
6

    
7
-}
8

    
9
import "hint" HLint.HLint
10
import "hint" HLint.Dollar
11

    
12
-- The following two hints warn to simplify e.g. "map (\v -> (v,
13
-- True)) lst" to "zip lst (repeat True)", which is more abstract
14
warn = map (\v -> (v, x)) y ==> zip y (repeat x)
15
  where _ = notIn v x
16
warn = map (\v -> (x, v)) ==> zip (repeat x)
17
  where _ = notIn v x
18

    
19
-- The following warn on use of length instead of null
20
warn = length x > 0 ==> not (null x)
21
warn = length x /= 0 ==> not (null x)
22
warn = length x == 0 ==> null x
23

    
24
-- Never use head, use 'case' which covers all possibilities
25
warn = head x ==> case x of { y:_ -> y } where note = "Head is unsafe, please use case and handle the empty list as well"
26

    
27
-- Never use tail, use 'case' which covers all possibilities
28
warn = tail x ==> case x of { _:y -> y } where note = "Tail is unsafe, please use case and handle the empty list as well"