diff --git a/rules/frappe_correctness.yml b/rules/frappe_correctness.yml index fa1ad4f..1529904 100644 --- a/rules/frappe_correctness.yml +++ b/rules/frappe_correctness.yml @@ -140,6 +140,23 @@ rules: languages: [python] severity: ERROR +- id: frappe-prefer-doctype-caster + patterns: + - pattern: | + def $MAKEFUNCTION(...): + ... + - metavariable-regex: + metavariable: $MAKEFUNCTION + regex: "^make_(.*)$" + message: | + This is an old pattern. Replace '$MAKEFUNCTION' with 'def _into_*(self, doc)' or 'def _from_*(self, doc)' instance conversion methods. + Check: https://github.com/frappe/frappe/pull/26991 for the implementation and https://github.com/frappe/erpnext/pull/42160/files for an example. + languages: [python] + severity: WARNING + paths: + include: + - "*/**/doctype/*" + - id: frappe-print-function-in-doctypes pattern: print(...) message: | diff --git a/rules/some/doctype/frappe_correctness.py b/rules/some/doctype/frappe_correctness.py new file mode 100644 index 0000000..af26dba --- /dev/null +++ b/rules/some/doctype/frappe_correctness.py @@ -0,0 +1,3 @@ +# ruleid: frappe-avoid-make-functions-prefer-doctype-caster +def make_sales_invoice(...): + ...