c2bd829fe2
Some of the core scheduler tests need the maximum batch size for writes to be smaller than the usual `structs.MaxUUIDsPerWriteRequest`. But they do so by unsafely modifying the global struct, which creates test flakes in other tests. Modify the functions under test to take a batch size parameter. Production code will pass the global while the tests can inject smaller values. Turn the `structs.MaxUUIDsPerWriteRequest` into a constant, and add a semgrep rule for avoiding this kind of thing in the future.
14 lines
279 B
YAML
14 lines
279 B
YAML
rules:
|
|
- id: "no-overriding-struct-globals"
|
|
patterns:
|
|
- pattern: |
|
|
structs.$A = ...
|
|
message: "Mutating global structs is never safe"
|
|
languages:
|
|
- "go"
|
|
severity: "ERROR"
|
|
fix: " "
|
|
paths:
|
|
# including tests!
|
|
include: ["*"]
|