# HG changeset patch # User FUJIWARA Katsunori # Date 2019-02-28 17:53:09 # Node ID 519b2faea261ad8d6c5024acc376752ace6e2754 # Parent 7a139fc60eb0d085861821d31c70c99357955405 contrib: change return value of file checking function of check-code.py This is a part of preparation to apply checking with check-code.py on code fragments embedded in *.t test scripts. After this patch, caller of _checkfiledata() can count number of errors in each code fragments of an actual file. This will be useful to share --per-file limitation by all embedded code fragments. diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -669,8 +669,9 @@ def checkfile(f, logfunc=_defaultlogger. print("Skipping %s it has no-che?k-code (glob)" % f) return "Skip" # skip checking this file - if not _checkfiledata(name, f, pre, filters, pats, context, - logfunc, maxerr, warnings, blame, debug, lineno): + fc = _checkfiledata(name, f, pre, filters, pats, context, + logfunc, maxerr, warnings, blame, debug, lineno) + if fc: result = False return result @@ -695,13 +696,12 @@ def _checkfiledata(name, f, filedata, fi :debug: whether debug information should be displayed :lineno: whether lineno should be displayed at error reporting - return True if no error is found, False otherwise. + returns number of detected errors. """ blamecache = context['blamecache'] fc = 0 pre = post = filedata - result = True if True: # TODO: get rid of this redundant 'if' block for p, r in filters: @@ -760,7 +760,6 @@ def _checkfiledata(name, f, filedata, fi bd = '%s@%s' % (bu, br) errors.append((f, lineno and n + 1, l, msg, bd)) - result = False errors.sort() for e in errors: @@ -770,7 +769,7 @@ def _checkfiledata(name, f, filedata, fi print(" (too many errors, giving up)") break - return result + return fc def main(): parser = optparse.OptionParser("%prog [options] [files | -]")