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: Detect incorrect use of `assertTrue`.

akshatdalton2e4a33313307
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py
index d0f87544efc..d7d7d3fe289 100644
--- a/tools/linter_lib/custom_check.py
+++ b/tools/linter_lib/custom_check.py
@@ -277,6 +277,16 @@ python_rules = RuleList(
"good_lines": ["assert_length(data, 2)"],
"bad_lines": ["assertEqual(len(data), 2)"],
},
+ {
+ "pattern": "assertTrue[(]len[(][^ ]*[)]",
+ "description": "Use assert_length or assertGreater helper instead of assertTrue(len(..) ..).",
+ "good_lines": ["assert_length(data, 2)", "assertGreater(len(data), 2)"],
+ "bad_lines": [
+ "assertTrue(len(data) == 2)",
+ "assertTrue(len(data) >= 2)",
+ "assertTrue(len(data) > 2)",
+ ],
+ },
{
"pattern": r"#\s*type:\s*ignore(?!\[[^][]+\] +# +\S)",
"exclude": {"tools/tests", "zerver/lib/test_runner.py", "zerver/tests"},