Mercurial > hg
changeset 14169:1b4b82063ce2
check-code: disallow calling opener(...).read() and opener(..).write()
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Mon, 02 May 2011 10:11:24 +0200 |
parents | 135e244776f0 |
children | 1a919c3271bf |
files | contrib/check-code.py |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-code.py Mon May 02 10:11:18 2011 +0200 +++ b/contrib/check-code.py Mon May 02 10:11:24 2011 +0200 @@ -161,6 +161,18 @@ (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'[\s\(](open|file)\([^)]*\)\.read\(', + "use util.readfile() instead"), + (r'[\s\(](open|file)\([^)]*\)\.write\(', + "use util.readfile() instead"), + (r'^[\s\(]*(open(er)?|file)\([^)]*\)', + "always assign an opened file to a variable, and close it afterwards"), + (r'[\s\(](open|file)\([^)]*\)\.', + "always assign an opened file to a variable, and close it afterwards"), ], # warnings [