-
Notifications
You must be signed in to change notification settings - Fork 18
/
.semgrep.yml
95 lines (95 loc) · 2.96 KB
/
.semgrep.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
rules:
- id: table-ctor-in-hot-loop
pattern-either:
- pattern: Draw.$X(..., {..., ..., ...}, ...)
- pattern: |
$X = {$X, $Y, $Z}
...
Draw.$Y(..., $X, ...)
- pattern: self.t.$X.$Y:$Z(..., {..., ..., ...}, ...)
- pattern:
$X = {$X, $Y, $Z}
...
self.t.$X.$Y:$Z(..., {$X, $Y, $Z}, ...)
- pattern: function $X:draw(...) ... $Y(..., {..., ..., ...}, ...) ... end
- pattern: function $X:update(...) ... $Y(..., {..., ..., ...}, ...) ... end
message: "Draw call passing table in hot loop"
languages: [lua]
paths:
exclude:
- src/mod/*/data/**/*.lua
severity: ERROR
- id: implicit-global-map-argument
pattern-either:
- pattern: Chara.create($X, $Y, $Z)
- pattern: Charagen.create($X, $Y, $Z)
- pattern: Item.create($X, $Y, $Z)
- pattern: Itemgen.create($X, $Y, $Z)
- pattern: Chara.create($X, $Y, $Z, $W)
- pattern: Charagen.create($X, $Y, $Z, $W)
- pattern: Item.create($X, $Y, $Z, $W)
- pattern: Itemgen.create($X, $Y, $Z, $W)
message: "Function with implicit global map argument"
languages: [lua]
paths:
exclude:
- src/mod/*/data/**/*.lua
severity: ERROR
- id: implicit-global-map-argument-in-defn
pattern-either:
- pattern: $X = $X or field.map
message: "Function definition with implicit global map argument"
languages: [lua]
paths:
exclude:
- src/mod/*/data/**/*.lua
severity: WARNING
- id: deprecated-ai-syntax
pattern-either:
- pattern: $X.ai_state
- pattern: $X.item_using
- pattern: $X:reset_reaction_at(...)
- pattern: $X:get_reaction_at(...)
- pattern: $X:base_reaction_towards(...)
- pattern: $X:reaction_towards(...)
- pattern: $X:reaction_towards(...)
- pattern: $X:mod_reaction_towards(...)
- pattern: $X:reset_all_reactions(...)
- pattern: $X:mod_hate_at(...)
- pattern: $X:set_hate_at(...)
- pattern: $X:get_hate_at(...)
- pattern: $X:is_allied()
- pattern: $X:is_ally()
- pattern: $X:set_target()
- pattern: $X:get_target()
- pattern: $X:get_party_leader()
- pattern: $X:reset_ai()
message: "Deprecated AI syntax"
languages: [lua]
paths:
exclude:
- src/mod/*/data/**/*.lua
severity: ERROR
- id: deprecated-functions
pattern-either:
- pattern: string.nonempty(...)
message: "Deprecated functions"
languages: [lua]
severity: ERROR
- id: assert-type-eq
pattern-either:
- pattern: assert(type($X) == $Y)
message: "Typecheck with plain `assert`; use `class.assert_is_an(...) instead`"
languages: [lua]
severity: WARNING
- id: require-inside-function
pattern-either:
- pattern:
function $X(...)
...
require(...)
...
end
message: "Call to `require()` inside function"
languages: [lua]
severity: WARNING