Show More
@@ -677,7 +677,8 b' def checkfile(f, logfunc=_defaultlogger.' | |||
|
677 | 677 | return result |
|
678 | 678 | |
|
679 | 679 | def _checkfiledata(name, f, filedata, filters, pats, context, |
|
680 |
logfunc, maxerr, warnings, blame, debug, lineno |
|
|
680 | logfunc, maxerr, warnings, blame, debug, lineno, | |
|
681 | offset=None): | |
|
681 | 682 | """Execute actual error check for file data |
|
682 | 683 | |
|
683 | 684 | :name: of the checking category |
@@ -695,10 +696,17 b' def _checkfiledata(name, f, filedata, fi' | |||
|
695 | 696 | :blame: whether blame information should be displayed at error reporting |
|
696 | 697 | :debug: whether debug information should be displayed |
|
697 | 698 | :lineno: whether lineno should be displayed at error reporting |
|
699 | :offset: line number offset of 'filedata' in 'f' for checking | |
|
700 | an embedded code fragment, or None (offset=0 is different | |
|
701 | from offset=None) | |
|
698 | 702 | |
|
699 | 703 | returns number of detected errors. |
|
700 | 704 | """ |
|
701 | 705 | blamecache = context['blamecache'] |
|
706 | if offset is None: | |
|
707 | lineoffset = 0 | |
|
708 | else: | |
|
709 | lineoffset = offset | |
|
702 | 710 | |
|
703 | 711 | fc = 0 |
|
704 | 712 | pre = post = filedata |
@@ -746,7 +754,7 b' def _checkfiledata(name, f, filedata, fi' | |||
|
746 | 754 | if ignore and re.search(ignore, l, re.MULTILINE): |
|
747 | 755 | if debug: |
|
748 | 756 | print("Skipping %s for %s:%s (ignore pattern)" % ( |
|
749 | name, f, n)) | |
|
757 | name, f, (n + lineoffset))) | |
|
750 | 758 | continue |
|
751 | 759 | bd = "" |
|
752 | 760 | if blame: |
@@ -754,12 +762,22 b' def _checkfiledata(name, f, filedata, fi' | |||
|
754 | 762 | if blamecache is None: |
|
755 | 763 | blamecache = getblame(f) |
|
756 | 764 | context['blamecache'] = blamecache |
|
757 | if n < len(blamecache): | |
|
758 | bl, bu, br = blamecache[n] | |
|
759 | if bl == l: | |
|
765 | if (n + lineoffset) < len(blamecache): | |
|
766 | bl, bu, br = blamecache[(n + lineoffset)] | |
|
767 | if offset is None and bl == l: | |
|
760 | 768 | bd = '%s@%s' % (bu, br) |
|
769 | elif offset is not None and bl.endswith(l): | |
|
770 | # "offset is not None" means "checking | |
|
771 | # embedded code fragment". In this case, | |
|
772 | # "l" does not have information about the | |
|
773 | # beginning of an *original* line in the | |
|
774 | # file (e.g. ' > '). | |
|
775 | # Therefore, use "str.endswith()", and | |
|
776 | # show "maybe" for a little loose | |
|
777 | # examination. | |
|
778 | bd = '%s@%s, maybe' % (bu, br) | |
|
761 | 779 | |
|
762 | errors.append((f, lineno and n + 1, l, msg, bd)) | |
|
780 | errors.append((f, lineno and (n + lineoffset + 1), l, msg, bd)) | |
|
763 | 781 | |
|
764 | 782 | errors.sort() |
|
765 | 783 | for e in errors: |
General Comments 0
You need to be logged in to leave comments.
Login now