[PATCH 2 of 2] check-code: disallow calling opener(...).read() and opener(..).write()
Dan Villiom Podlaski Christiansen
danchr at gmail.com
Sun May 1 05:32:40 CDT 2011
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1304243238 -7200
# Node ID a837eba99821f832562f934e31d2a5819eb9bfbc
# Parent ddebfda06862e0cb975ccf69a12c5a27214ad41f
check-code: disallow calling opener(...).read() and opener(..).write()
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -161,6 +161,18 @@ pypats = [
(r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
(r' [=!]=\s+(True|False|None)',
"comparison with singleton, use 'is' or 'is not' instead"),
+ (r'opener\([^)]*\).read\(',
+ "use opener.read() instead"),
+ (r'opener\([^)]*\).write\(',
+ "use opener.write() instead"),
+ (r'open\([^)]*\)\.read\(',
+ "use util.readfile() instead"),
+ (r'open\([^)]*\)\.write\(',
+ "use util.readfile() instead"),
+ (r'^\s*open(er)?\([^)]*\)',
+ "always assign an opened file to a variable, and close it afterwards"),
+ (r'open\([^)]*\)\.',
+ "always assign an opened file to a variable, and close it afterwards"),
],
# warnings
[
More information about the Mercurial-devel
mailing list