Mercurial > hg
comparison contrib/check-code.py @ 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 | 83a94c2fe6f4 |
children | b230922eb0c3 |
comparison
equal
deleted
inserted
replaced
14168:135e244776f0 | 14169:1b4b82063ce2 |
---|---|
159 "wrong whitespace around ="), | 159 "wrong whitespace around ="), |
160 (r'raise Exception', "don't raise generic exceptions"), | 160 (r'raise Exception', "don't raise generic exceptions"), |
161 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"), | 161 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"), |
162 (r' [=!]=\s+(True|False|None)', | 162 (r' [=!]=\s+(True|False|None)', |
163 "comparison with singleton, use 'is' or 'is not' instead"), | 163 "comparison with singleton, use 'is' or 'is not' instead"), |
164 (r'opener\([^)]*\).read\(', | |
165 "use opener.read() instead"), | |
166 (r'opener\([^)]*\).write\(', | |
167 "use opener.write() instead"), | |
168 (r'[\s\(](open|file)\([^)]*\)\.read\(', | |
169 "use util.readfile() instead"), | |
170 (r'[\s\(](open|file)\([^)]*\)\.write\(', | |
171 "use util.readfile() instead"), | |
172 (r'^[\s\(]*(open(er)?|file)\([^)]*\)', | |
173 "always assign an opened file to a variable, and close it afterwards"), | |
174 (r'[\s\(](open|file)\([^)]*\)\.', | |
175 "always assign an opened file to a variable, and close it afterwards"), | |
164 ], | 176 ], |
165 # warnings | 177 # warnings |
166 [ | 178 [ |
167 (r'.{81}', "warning: line over 80 characters"), | 179 (r'.{81}', "warning: line over 80 characters"), |
168 (r'^\s*except:$', "warning: naked except clause"), | 180 (r'^\s*except:$', "warning: naked except clause"), |