From 1f1841d23225eac3131d466e601eed09936f83ff Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Wed, 1 Sep 2021 14:27:00 +0530 Subject: [PATCH] ci(semgrep): add translation checks for report labels (#27280) (#27286) * ci(semgrep): add translation checks for report labels * refactor: shift report tests to it's own yml path can't be applied on a test id basis * ci: ignore regional report in translation checks [skip ci] (cherry picked from commit 72ece75b114524ab2ab4a2b39674b185a21eb9bd) Co-authored-by: Alan <2.alan.tom@gmail.com> --- .github/helper/semgrep_rules/report.py | 15 +++++++++++++++ .github/helper/semgrep_rules/report.yml | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/helper/semgrep_rules/report.py create mode 100644 .github/helper/semgrep_rules/report.yml diff --git a/.github/helper/semgrep_rules/report.py b/.github/helper/semgrep_rules/report.py new file mode 100644 index 00000000000..ff278408e18 --- /dev/null +++ b/.github/helper/semgrep_rules/report.py @@ -0,0 +1,15 @@ +from frappe import _ + + +# ruleid: frappe-missing-translate-function-in-report-python +{"label": "Field Label"} + +# ruleid: frappe-missing-translate-function-in-report-python +dict(label="Field Label") + + +# ok: frappe-missing-translate-function-in-report-python +{"label": _("Field Label")} + +# ok: frappe-missing-translate-function-in-report-python +dict(label=_("Field Label")) diff --git a/.github/helper/semgrep_rules/report.yml b/.github/helper/semgrep_rules/report.yml new file mode 100644 index 00000000000..7f3dd011dc1 --- /dev/null +++ b/.github/helper/semgrep_rules/report.yml @@ -0,0 +1,21 @@ +rules: +- id: frappe-missing-translate-function-in-report-python + paths: + include: + - "**/report" + exclude: + - "**/regional" + pattern-either: + - patterns: + - pattern: | + {..., "label": "...", ...} + - pattern-not: | + {..., "label": _("..."), ...} + - patterns: + - pattern: dict(..., label="...", ...) + - pattern-not: dict(..., label=_("..."), ...) + message: | + All user facing text must be wrapped in translate function. Please refer to translation documentation. https://frappeframework.com/docs/user/en/guides/basics/translations + languages: [python] + severity: ERROR +