201 (r'[\s\(](open|file)\([^)]*\)\.', |
201 (r'[\s\(](open|file)\([^)]*\)\.', |
202 "always assign an opened file to a variable, and close it afterwards"), |
202 "always assign an opened file to a variable, and close it afterwards"), |
203 (r'(?i)descendent', "the proper spelling is descendAnt"), |
203 (r'(?i)descendent', "the proper spelling is descendAnt"), |
204 (r'\.debug\(\_', "don't mark debug messages for translation"), |
204 (r'\.debug\(\_', "don't mark debug messages for translation"), |
205 (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"), |
205 (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"), |
206 ], |
206 (r'^\s*except\s*:', "warning: naked except clause", r'#.*re-raises'), |
207 # warnings |
207 ], |
208 [ |
208 # warnings |
209 (r'^\s*except\s*:', "warning: naked except clause"), |
209 [ |
210 (r'ui\.(status|progress|write|note|warn)\([\'\"]x', |
210 (r'ui\.(status|progress|write|note|warn)\([\'\"]x', |
211 "warning: unwrapped ui message"), |
211 "warning: unwrapped ui message"), |
212 ] |
212 ] |
213 ] |
213 ] |
214 |
214 |
353 if debug: |
353 if debug: |
354 print "Checking %s for %s" % (name, f) |
354 print "Checking %s for %s" % (name, f) |
355 |
355 |
356 prelines = None |
356 prelines = None |
357 errors = [] |
357 errors = [] |
358 for p, msg in pats: |
358 for pat in pats: |
|
359 if len(pat) == 3: |
|
360 p, msg, ignore = pat |
|
361 else: |
|
362 p, msg = pat |
|
363 ignore = None |
|
364 |
359 # fix-up regexes for multiline searches |
365 # fix-up regexes for multiline searches |
360 po = p |
366 po = p |
361 # \s doesn't match \n |
367 # \s doesn't match \n |
362 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p) |
368 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p) |
363 # [^...] doesn't match newline |
369 # [^...] doesn't match newline |