forked from goblint/analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.yml
77 lines (73 loc) · 2.73 KB
/
list.yml
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
rules:
- id: list-length-compare-0
pattern-either:
- pattern: List.length $L = 0
- pattern: List.length $L <> 0
- pattern: List.length $L > 0
- pattern: List.length $L >= 1
# doesn't find in ValueDomain: List.length ci.cfields > 0
# doesn't find in MyLiveness: List.length s.labels = 0
message: computing list length is inefficient for emptiness checking, compare with [] instead
languages: [ocaml]
severity: WARNING
- id: list-length-compare-n
patterns:
- pattern-either:
- pattern: List.length $L = $N
- pattern: List.length $L <> $N
- pattern: List.length $L > $N
- pattern: List.length $L >= $N
- pattern: List.length $L < $N
- pattern: List.length $L <= $N
- metavariable-pattern:
metavariable: $N
patterns:
- pattern-not: "0" # covered by list-length-compare-0
- pattern-not: List.length ... # covered by list-length-compare-list-length
message: computing list length is inefficient for length comparison, use compare_length_with instead
languages: [ocaml]
severity: WARNING
- id: list-length-compare-list-length
pattern-either:
- pattern: List.length $L1 = List.length $L2
- pattern: List.length $L1 <> List.length $L2
- pattern: List.length $L1 > List.length $L2
- pattern: List.length $L1 >= List.length $L2
- pattern: List.length $L1 < List.length $L2
- pattern: List.length $L1 <= List.length $L2
message: computing list length is inefficient for length comparison, use compare_lengths instead
languages: [ocaml]
severity: WARNING
- id: list-function-temporary-combine
patterns:
- pattern: $LF ... (List.combine ... ...)
- metavariable-pattern:
metavariable: $LF
pattern-either:
- pattern: List.iter
- pattern: List.iteri
- pattern: List.map
- pattern: List.mapi
- pattern: List.rev_map
- pattern: List.fold_left
- pattern: List.fold_right
- pattern: List.for_all
- pattern: List.exists
message: unnecessary temporary combined list, use 2-suffixed operation directly
languages: [ocaml]
severity: WARNING
- id: list-map-flatten
patterns:
- pattern-either:
- pattern: $LF (List.map ... ...)
- pattern: $LF @@ List.map ... ...
- pattern: List.map ... ... |> $LF
- pattern: (... |> List.map ... ...) |> $LF
- metavariable-pattern:
metavariable: $LF
pattern-either:
- pattern: List.flatten
- pattern: List.concat
message: use List.concat_map instead
languages: [ocaml]
severity: WARNING