mirror of https://github.com/zulip/zulip.git
semgrep: Add rule to specify tick kwarg on time_machine.travel() calls.
Letting the clock tick without a reason introduces the possibility of nondeterministic test failures depending on the execution time. The default value when not specified is tick=True, which makes it easy to miss. The rule doesn't prohibit setting tick=True, as perhaps there will be tests wanting to use that feature on purpose, but such a test should explicitly set it to make the intent clear.
This commit is contained in:
parent
11390b70be
commit
0e4532f8e7
|
@ -17,6 +17,15 @@ rules:
|
||||||
include:
|
include:
|
||||||
- zerver/views/
|
- zerver/views/
|
||||||
|
|
||||||
|
- id: time-machine-travel-specify-tick
|
||||||
|
patterns:
|
||||||
|
- pattern: time_machine.travel(...)
|
||||||
|
- pattern-not: time_machine.travel(..., tick=..., ...)
|
||||||
|
message: |
|
||||||
|
Specify tick kwarg value for time_machine.travel(). Most cases will want to use False.
|
||||||
|
languages: [python]
|
||||||
|
severity: ERROR
|
||||||
|
|
||||||
- id: limit-message-filter
|
- id: limit-message-filter
|
||||||
patterns:
|
patterns:
|
||||||
- pattern: Message.objects.filter(...)
|
- pattern: Message.objects.filter(...)
|
||||||
|
|
Loading…
Reference in New Issue