-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckers_maphash.go
67 lines (60 loc) · 1.51 KB
/
checkers_maphash.go
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
package mirror
import "github.com/butuzov/mirror/internal/checker"
var (
MaphashFunctions = []checker.Violation{
{ // maphash.Bytes
Targets: checker.Bytes,
Type: checker.Function,
Package: "hash/maphash",
Caller: "Bytes",
Args: []int{1},
AltCaller: "String",
Generate: &checker.Generate{
Pattern: `Bytes(maphash.MakeSeed(), $0)`,
Returns: []string{"uint64"},
},
},
{ // maphash.String
Targets: checker.Strings,
Type: checker.Function,
Package: "hash/maphash",
Caller: "String",
Args: []int{1},
AltCaller: "Bytes",
Generate: &checker.Generate{
Pattern: `String(maphash.MakeSeed(), $0)`,
Returns: []string{"uint64"},
},
},
}
MaphashMethods = []checker.Violation{
{ // (*hash/maphash).Write
Targets: checker.Bytes,
Type: checker.Method,
Package: "hash/maphash",
Struct: "Hash",
Caller: "Write",
Args: []int{0},
AltCaller: "WriteString",
Generate: &checker.Generate{
PreCondition: `h := maphash.Hash{}`,
Pattern: `Write($0)`,
Returns: []string{"int", "error"},
},
},
{ // (*hash/maphash).WriteString
Targets: checker.Strings,
Type: checker.Method,
Package: "hash/maphash",
Struct: "Hash",
Caller: "WriteString",
Args: []int{0},
AltCaller: "Write",
Generate: &checker.Generate{
PreCondition: `h := maphash.Hash{}`,
Pattern: `WriteString($0)`,
Returns: []string{"int", "error"},
},
},
}
)