Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

custom_check: Enforce use of assert_length helper.

Abhijeet Prasad Bodas0ec905ed521b
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py
index 7f0faeeeddd..3b48a965c35 100644
--- a/tools/linter_lib/custom_check.py
+++ b/tools/linter_lib/custom_check.py
@@ -267,6 +267,12 @@ python_rules = RuleList(
"good_lines": ["assertEqual(1, 2)"],
"bad_lines": ["assertEquals(1, 2)"],
},
+ {
+ "pattern": "assertEqual[(]len[(][^ ]*[)],",
+ "description": "Use the assert_length helper instead of assertEqual(len(..), ..).",
+ "good_lines": ["assert_length(data, 2)"],
+ "bad_lines": ["assertEqual(len(data), 2)"],
+ },
{
"pattern": r"#\s*type:\s*ignore(?!\[[^][]+\] +# +\S)",
"exclude": {"tools/tests", "zerver/lib/test_runner.py", "zerver/tests"},