From: Daira Hopwood Date: Thu, 5 Sep 2013 18:10:24 +0000 (+0100) Subject: Sun Oct 9 06:03:01 BST 2011 david-sarah@jacaranda.org X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/statistics?a=commitdiff_plain;h=a6c64e44c8e0b9c428faa645881ec90935b5f518;p=tahoe-lafs%2Ftahoe-lafs.git Sun Oct 9 06:03:01 BST 2011 david-sarah@jacaranda.org * check-miscaptures.py: report the number of files that were not analysed due to syntax errors (and don't count them in the number of suspicious captures). refs #1555 --- diff --git a/misc/coding_tools/check-miscaptures.py b/misc/coding_tools/check-miscaptures.py index f7950a92..498d8bc9 100644 --- a/misc/coding_tools/check-miscaptures.py +++ b/misc/coding_tools/check-miscaptures.py @@ -14,7 +14,7 @@ def check_thing(parser, thing): try: ast = parser(thing) except SyntaxError, e: - return [e] + return e else: results = [] check_ast(ast, results) @@ -114,25 +114,27 @@ def make_result(funcnode, var_name, var_lineno): def report(out, path, results): for r in results: - if isinstance(r, SyntaxError): - print >>out, path + (" NOT ANALYSED due to syntax error: %s" % r) - else: - print >>out, path + (":%r %s captures %r declared at line %d" % r) + print >>out, path + (":%r %s captures %r declared at line %d" % r) def check(sources, out): class Counts: n = 0 processed_files = 0 suspect_files = 0 + error_files = 0 counts = Counts() def _process(path): results = check_file(path) - report(out, path, results) - counts.n += len(results) - counts.processed_files += 1 - if len(results) > 0: - counts.suspect_files += 1 + if isinstance(results, SyntaxError): + print >>out, path + (" NOT ANALYSED due to syntax error: %s" % results) + counts.error_files += 1 + else: + report(out, path, results) + counts.n += len(results) + counts.processed_files += 1 + if len(results) > 0: + counts.suspect_files += 1 for source in sources: print >>out, "Checking %s..." % (source,) @@ -145,8 +147,11 @@ def check(sources, out): if ext == '.py': _process(os.path.join(dirpath, fn)) - print >>out, ("%d suspiciously captured variables in %d out of %d files" + print >>out, ("%d suspiciously captured variables in %d out of %d file(s)." % (counts.n, counts.suspect_files, counts.processed_files)) + if counts.error_files > 0: + print >>out, ("%d file(s) not processed due to syntax errors." + % (counts.error_files,)) return counts.n