mirror of https://github.com/zulip/zulip.git
lint: Ban use of Stream.objects.* in zerver/views.
This commit is contained in:
parent
bb86bba20d
commit
de68dd2860
|
@ -194,6 +194,13 @@ def build_custom_checkers(by_lang):
|
||||||
exclude_list = rule.get('exclude_line', set())
|
exclude_list = rule.get('exclude_line', set())
|
||||||
if (fn, line_fully_stripped) in exclude_list:
|
if (fn, line_fully_stripped) in exclude_list:
|
||||||
continue
|
continue
|
||||||
|
if rule.get("include_only"):
|
||||||
|
found = False
|
||||||
|
for item in rule.get("include_only", set()):
|
||||||
|
if item in fn:
|
||||||
|
found = True
|
||||||
|
if not found:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
line_to_check = line_fully_stripped
|
line_to_check = line_fully_stripped
|
||||||
if rule.get('strip') is not None:
|
if rule.get('strip') is not None:
|
||||||
|
@ -402,6 +409,14 @@ def build_custom_checkers(by_lang):
|
||||||
'exclude': set(["zerver/tests", "zerver/worker/queue_processors.py"]),
|
'exclude': set(["zerver/tests", "zerver/worker/queue_processors.py"]),
|
||||||
'description': 'Please use access_message() to fetch Message objects',
|
'description': 'Please use access_message() to fetch Message objects',
|
||||||
},
|
},
|
||||||
|
{'pattern': '[S]tream.objects.get',
|
||||||
|
'include_only': set(["zerver/views/"]),
|
||||||
|
'description': 'Please use access_stream_by_*() to fetch Stream objects',
|
||||||
|
},
|
||||||
|
{'pattern': '[S]tream.objects.filter',
|
||||||
|
'include_only': set(["zerver/views/"]),
|
||||||
|
'description': 'Please use access_stream_by_*() to fetch Stream objects',
|
||||||
|
},
|
||||||
# This rule might give false positives in virtualenv setup files which should be excluded,
|
# This rule might give false positives in virtualenv setup files which should be excluded,
|
||||||
# and comments which should be rewritten to avoid use of "python2", "python3", etc.
|
# and comments which should be rewritten to avoid use of "python2", "python3", etc.
|
||||||
{'pattern': 'python[23]',
|
{'pattern': 'python[23]',
|
||||||
|
|
Loading…
Reference in New Issue