-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.yml
More file actions
81 lines (74 loc) · 2.68 KB
/
rules.yml
File metadata and controls
81 lines (74 loc) · 2.68 KB
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
rules:
- id: require-include-in-schema
languages:
- python
severity: ERROR
message: Found a route that doesn't explicitly set include_in_schema.
patterns:
- pattern-inside: |
$ROUTER = ninja.Router(...)
...
- pattern: $ROUTER.$OPERATION(...)
- pattern-not: $ROUTER.$OPERATION(..., include_in_schema=..., ...)
- metavariable-regex:
metavariable: $OPERATION
regex: ^(get|post|delete|put|patch)$
- id: require-delay-on-commit
languages:
- python
severity: ERROR
message: Found a call to a celery task that runs before transaction commit.
pattern: $TASK.delay($...ARGS)
fix: $TASK.delay_on_commit($...ARGS)
- id: require-celery-timeouts
languages:
- python
severity: ERROR
message: Found a celery task definition that doesn't set timeouts.
patterns:
- pattern: shared_task(...)
- pattern-not: shared_task(..., soft_time_limit=..., time_limit=..., ...)
- id: require-elidable-arg-in-migration-operations
languages:
- python
severity: ERROR
message: Found a migration operation that doesn't set elidable.
pattern-either:
- patterns:
- pattern: django.db.migrations.RunPython(...)
- pattern-not: django.db.migrations.RunPython(..., elidable=..., ...)
- patterns:
- pattern: django.db.migrations.RunSQL(...)
- pattern-not: django.db.migrations.RunSQL(..., elidable=..., ...)
- id: require-csv-dict-writer
languages:
- python
severity: ERROR
message: Found a call to a regular csv writer, use EscapingDictWriter instead.
pattern: csv.writer(...)
- id: require-escaping-csv-dict-writer
languages:
- python
severity: ERROR
message: Found a call to a csv writer that doesn't escape values, use EscapingDictWriter instead.
pattern: csv.DictWriter($...ARGS)
fix: EscapingDictWriter($...ARGS)
- id: use-image-blob-where-possible
languages:
- python
- html
severity: ERROR
message: Use image.blob where possible, as it points to the correct accession blob
# this is a bit of a janky regex to try to catch image.accession.*blob usage
pattern-either:
- pattern-regex: image\.accession\.blob[.\s,\)]
- pattern-regex: image\.accession\.sponsored_blob[.\s,\)]
- id: use-image-thumbnail-256-where-possible
languages:
- python
- html
severity: ERROR
message: Use image.thumbnail_256 where possible, as it points to the correct accession thumbnail_256
pattern-either:
- pattern-regex: image\.accession\.thumbnail_256[.\s,\)]
- pattern-regex: image\.accession\.sponsored_thumbnail_256_blob[.\s,\)]