-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move
- Loading branch information
Showing
6 changed files
with
177 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import frappe | ||
from frappe import _ | ||
from frappe.model.document import Document | ||
|
||
|
||
# ruleid: frappe-modifying-but-not-comitting | ||
def on_submit(self): | ||
if self.value_of_goods == 0: | ||
frappe.throw(_('Value of goods cannot be 0')) | ||
self.status = 'Submitted' | ||
|
||
|
||
# ok: frappe-modifying-but-not-comitting | ||
def on_submit(self): | ||
if self.value_of_goods == 0: | ||
frappe.throw(_('Value of goods cannot be 0')) | ||
self.status = 'Submitted' | ||
self.db_set('status', 'Submitted') | ||
|
||
# ok: frappe-modifying-but-not-comitting | ||
def on_submit(self): | ||
if self.value_of_goods == 0: | ||
frappe.throw(_('Value of goods cannot be 0')) | ||
x = "y" | ||
self.status = x | ||
self.db_set('status', x) | ||
|
||
|
||
# ok: frappe-modifying-but-not-comitting | ||
def on_submit(self): | ||
x = "y" | ||
self.status = x | ||
self.save() | ||
|
||
# ruleid: frappe-modifying-but-not-comitting-other-method | ||
class DoctypeClass(Document): | ||
def on_submit(self): | ||
self.good_method() | ||
self.tainted_method() | ||
|
||
def tainted_method(self): | ||
self.status = "uptate" | ||
|
||
|
||
# ok: frappe-modifying-but-not-comitting-other-method | ||
class DoctypeClass(Document): | ||
def on_submit(self): | ||
self.good_method() | ||
self.tainted_method() | ||
|
||
def tainted_method(self): | ||
self.status = "update" | ||
self.db_set("status", "update") | ||
|
||
# ok: frappe-modifying-but-not-comitting-other-method | ||
class DoctypeClass(Document): | ||
def on_submit(self): | ||
self.good_method() | ||
self.tainted_method() | ||
self.save() | ||
|
||
def tainted_method(self): | ||
self.status = "uptate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def function_name(input): | ||
# ruleid: frappe-codeinjection-eval | ||
eval(input) | ||
|
||
# ok: frappe-codeinjection-eval | ||
eval("1 + 1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Examples taken from https://frappeframework.com/docs/user/en/translations | ||
# This file is used for testing the tests. | ||
|
||
from frappe import _ | ||
|
||
full_name = "Jon Doe" | ||
# ok: frappe-translation-python-formatting | ||
_('Welcome {0}, get started with ERPNext in just a few clicks.').format(full_name) | ||
|
||
# ruleid: frappe-translation-python-formatting | ||
_('Welcome %s, get started with ERPNext in just a few clicks.' % full_name) | ||
# ruleid: frappe-translation-python-formatting | ||
_('Welcome %(name)s, get started with ERPNext in just a few clicks.' % {'name': full_name}) | ||
|
||
# ruleid: frappe-translation-python-formatting | ||
_('Welcome {0}, get started with ERPNext in just a few clicks.'.format(full_name)) | ||
|
||
|
||
subscribers = ["Jon", "Doe"] | ||
# ok: frappe-translation-python-formatting | ||
_('You have {0} subscribers in your mailing list.').format(len(subscribers)) | ||
|
||
# ruleid: frappe-translation-python-splitting | ||
_('You have') + len(subscribers) + _('subscribers in your mailing list.') | ||
|
||
# ruleid: frappe-translation-python-splitting | ||
_('You have {0} subscribers \ | ||
in your mailing list').format(len(subscribers)) | ||
|
||
# ok: frappe-translation-python-splitting | ||
_('You have {0} subscribers') \ | ||
+ 'in your mailing list' | ||
|
||
# ruleid: frappe-translation-trailing-spaces | ||
msg = _(" You have {0} pending invoice ") | ||
# ruleid: frappe-translation-trailing-spaces | ||
msg = _("You have {0} pending invoice ") | ||
# ruleid: frappe-translation-trailing-spaces | ||
msg = _(" You have {0} pending invoice") | ||
|
||
# ok: frappe-translation-trailing-spaces | ||
msg = ' ' + _("You have {0} pending invoices") + ' ' | ||
|
||
# ruleid: frappe-translation-python-formatting | ||
_(f"can not format like this - {subscribers}") | ||
# ruleid: frappe-translation-python-splitting | ||
_(f"what" + f"this is also not cool") | ||
|
||
|
||
# ruleid: frappe-translation-empty-string | ||
_("") | ||
# ruleid: frappe-translation-empty-string | ||
_('') | ||
|
||
|
||
class Test: | ||
# ok: frappe-translation-python-splitting | ||
def __init__( | ||
args | ||
): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import frappe | ||
from frappe import _, msgprint, throw | ||
|
||
# ruleid: frappe-missing-translate-function-python | ||
throw("Error Occured") | ||
|
||
# ruleid: frappe-missing-translate-function-python | ||
frappe.throw("Error Occured") | ||
|
||
# ruleid: frappe-missing-translate-function-python | ||
frappe.msgprint("Useful message") | ||
|
||
# ruleid: frappe-missing-translate-function-python | ||
msgprint("Useful message") | ||
|
||
|
||
# ok: frappe-missing-translate-function-python | ||
translatedmessage = _("Hello") | ||
|
||
# ok: frappe-missing-translate-function-python | ||
throw(translatedmessage) | ||
|
||
# ok: frappe-missing-translate-function-python | ||
msgprint(translatedmessage) | ||
|
||
# ok: frappe-missing-translate-function-python | ||
msgprint(_("Helpful message")) | ||
|
||
# ok: frappe-missing-translate-function-python | ||
frappe.throw(_("Error occured")) |