Mercurial > hg
changeset 15502:7917a104a285
check-code: add --nolineno option for hiding line numbers
This makes the output more stable when it is used as a whitelist.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 11 Nov 2011 01:25:47 +0100 |
parents | 2371f4aea665 |
children | eb5ed02d8743 |
files | contrib/check-code.py tests/test-check-code.t |
diffstat | 2 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-code.py Wed Nov 16 18:04:19 2011 -0600 +++ b/contrib/check-code.py Fri Nov 11 01:25:47 2011 +0100 @@ -302,7 +302,7 @@ return lines def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False, - blame=False, debug=False): + blame=False, debug=False, lineno=True): """checks style and portability of a given file :f: filepath @@ -385,7 +385,7 @@ bl, bu, br = blamecache[n] if bl == l: bd = '%s@%s' % (bu, br) - errors.append((f, n + 1, l, msg, bd)) + errors.append((f, lineno and n + 1, l, msg, bd)) result = False errors.sort() @@ -408,8 +408,11 @@ help="use annotate to generate blame info") parser.add_option("", "--debug", action="store_true", help="show debug information") + parser.add_option("", "--nolineno", action="store_false", + dest='lineno', help="don't show line numbers") - parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False) + parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False, + lineno=True) (options, args) = parser.parse_args() if len(args) == 0: @@ -420,6 +423,7 @@ for f in check: ret = 0 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings, - blame=options.blame, debug=options.debug): + blame=options.blame, debug=options.debug, + lineno=options.lineno): ret = 1 sys.exit(ret)
--- a/tests/test-check-code.t Wed Nov 16 18:04:19 2011 -0600 +++ b/tests/test-check-code.t Fri Nov 11 01:25:47 2011 +0100 @@ -132,3 +132,11 @@ object comparison with literal [1] + $ cat > warning.py <<EOF + > except: + > EOF + $ "$check_code" warning.py --warning --nolineno + warning.py:0: + > except: + warning: naked except clause + [1]