Show More
@@ -635,7 +635,6 b' def checkfile(f, logfunc=_defaultlogger.' | |||
|
635 | 635 | |
|
636 | 636 | return True if no error is found, False otherwise. |
|
637 | 637 | """ |
|
638 | blamecache = None | |
|
639 | 638 | result = True |
|
640 | 639 | |
|
641 | 640 | try: |
@@ -649,11 +648,12 b' def checkfile(f, logfunc=_defaultlogger.' | |||
|
649 | 648 | print("Skipping %s, %s" % (f, str(e).split(':', 1)[0])) |
|
650 | 649 | return result |
|
651 | 650 | |
|
651 | # context information shared while single checkfile() invocation | |
|
652 | context = {'blamecache': None} | |
|
653 | ||
|
652 | 654 | for name, match, magic, filters, pats in checks: |
|
653 | post = pre # discard filtering result of previous check | |
|
654 | 655 | if debug: |
|
655 | 656 | print(name, f) |
|
656 | fc = 0 | |
|
657 | 657 | if not (re.match(match, f) or (magic and re.search(magic, pre))): |
|
658 | 658 | if debug: |
|
659 | 659 | print("Skipping %s for %s it doesn't match %s" % ( |
@@ -668,6 +668,42 b' def checkfile(f, logfunc=_defaultlogger.' | |||
|
668 | 668 | # tests/test-check-code.t |
|
669 | 669 | print("Skipping %s it has no-che?k-code (glob)" % f) |
|
670 | 670 | return "Skip" # skip checking this file |
|
671 | ||
|
672 | if not _checkfiledata(name, f, pre, filters, pats, context, | |
|
673 | logfunc, maxerr, warnings, blame, debug, lineno): | |
|
674 | result = False | |
|
675 | ||
|
676 | return result | |
|
677 | ||
|
678 | def _checkfiledata(name, f, filedata, filters, pats, context, | |
|
679 | logfunc, maxerr, warnings, blame, debug, lineno): | |
|
680 | """Execute actual error check for file data | |
|
681 | ||
|
682 | :name: of the checking category | |
|
683 | :f: filepath | |
|
684 | :filedata: content of a file | |
|
685 | :filters: to be applied before checking | |
|
686 | :pats: to detect errors | |
|
687 | :context: a dict of information shared while single checkfile() invocation | |
|
688 | Valid keys: 'blamecache'. | |
|
689 | :logfunc: function used to report error | |
|
690 | logfunc(filename, linenumber, linecontent, errormessage) | |
|
691 | :maxerr: number of error to display before aborting, or False to | |
|
692 | report all errors | |
|
693 | :warnings: whether warning level checks should be applied | |
|
694 | :blame: whether blame information should be displayed at error reporting | |
|
695 | :debug: whether debug information should be displayed | |
|
696 | :lineno: whether lineno should be displayed at error reporting | |
|
697 | ||
|
698 | return True if no error is found, False otherwise. | |
|
699 | """ | |
|
700 | blamecache = context['blamecache'] | |
|
701 | ||
|
702 | fc = 0 | |
|
703 | pre = post = filedata | |
|
704 | result = True | |
|
705 | ||
|
706 | if True: # TODO: get rid of this redundant 'if' block | |
|
671 | 707 | for p, r in filters: |
|
672 | 708 | post = re.sub(p, r, post) |
|
673 | 709 | nerrs = len(pats[0]) # nerr elements are errors |
@@ -715,8 +751,9 b' def checkfile(f, logfunc=_defaultlogger.' | |||
|
715 | 751 | bd = "" |
|
716 | 752 | if blame: |
|
717 | 753 | bd = 'working directory' |
|
718 |
if |
|
|
754 | if blamecache is None: | |
|
719 | 755 | blamecache = getblame(f) |
|
756 | context['blamecache'] = blamecache | |
|
720 | 757 | if n < len(blamecache): |
|
721 | 758 | bl, bu, br = blamecache[n] |
|
722 | 759 | if bl == l: |
General Comments 0
You need to be logged in to leave comments.
Login now