mirror of https://github.com/zulip/zulip.git
semgrep: Check if a batched migration is made atomic.
This raises an error when we forget to make migration non-atomic when doing it in batches. BATCH_SIZE seems to be a good indicator for when we do batching with few early exceptions. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
a472667ca1
commit
119cf9100c
|
@ -134,3 +134,22 @@ rules:
|
|||
- zerver/tests/
|
||||
message: "Do not fetch a Confirmation object directly, use get_object_from_key instead"
|
||||
severity: ERROR
|
||||
|
||||
- id: dont-make-batched-migration-atomic
|
||||
patterns:
|
||||
- pattern: |
|
||||
class Migration(migrations.Migration):
|
||||
...
|
||||
- pattern-inside: |
|
||||
...
|
||||
BATCH_SIZE = ...
|
||||
...
|
||||
- pattern-not: |
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
paths:
|
||||
include:
|
||||
- "**/migrations"
|
||||
message: 'A batched migration should not be atomic. Add "atomic = False" to the Migration class'
|
||||
languages: [python]
|
||||
severity: ERROR
|
||||
|
|
Loading…
Reference in New Issue