mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 02:01:21 +00:00
Adds semgrep testing in CI. Refer to: - https://github.com/frappe/frappe/pull/12524 - https://github.com/frappe/frappe/pull/12577
57 lines
1.5 KiB
YAML
57 lines
1.5 KiB
YAML
# This file specifies rules for correctness according to how frappe doctype data model works.
|
|
|
|
rules:
|
|
- id: frappe-modifying-after-submit
|
|
patterns:
|
|
- pattern: self.$ATTR = ...
|
|
- pattern-inside: |
|
|
def on_submit(self, ...):
|
|
...
|
|
message: |
|
|
Doctype modified after submission. Please check if modification of self.$ATTR is commited to database.
|
|
languages: [python]
|
|
severity: ERROR
|
|
|
|
- id: frappe-print-function-in-doctypes
|
|
pattern: print(...)
|
|
message: |
|
|
Did you mean to leave this print statement in? Consider using msgprint or logger instead of print statement.
|
|
languages: [python]
|
|
severity: WARNING
|
|
paths:
|
|
exclude:
|
|
- test_*.py
|
|
include:
|
|
- "*/**/doctype/*"
|
|
|
|
- id: frappe-modifying-child-tables-while-iterating
|
|
pattern-either:
|
|
- pattern: |
|
|
for $ROW in self.$TABLE:
|
|
...
|
|
self.remove(...)
|
|
- pattern: |
|
|
for $ROW in self.$TABLE:
|
|
...
|
|
self.append(...)
|
|
message: |
|
|
Child table being modified while iterating on it.
|
|
languages: [python]
|
|
severity: ERROR
|
|
paths:
|
|
include:
|
|
- "*/**/doctype/*"
|
|
|
|
- id: frappe-same-key-assigned-twice
|
|
pattern-either:
|
|
- pattern: |
|
|
{..., $X: $A, ..., $X: $B, ...}
|
|
- pattern: |
|
|
dict(..., ($X, $A), ..., ($X, $B), ...)
|
|
- pattern: |
|
|
_dict(..., ($X, $A), ..., ($X, $B), ...)
|
|
message: |
|
|
key `$X` is uselessly assigned twice. This could be a potential bug.
|
|
languages: [python]
|
|
severity: ERROR
|