Merge remote-tracking branch 'upstream-public/pr/2219' into development
This commit is contained in:
commit
8ef1f48a52
1 changed files with 28 additions and 3 deletions
|
@ -43,11 +43,14 @@ class IssueTracker(object):
|
||||||
for i, line in enumerate(iter(f.readline, b"")):
|
for i, line in enumerate(iter(f.readline, b"")):
|
||||||
self.check_file_line(filepath, line, i + 1)
|
self.check_file_line(filepath, line, i + 1)
|
||||||
|
|
||||||
|
def record_issue(self, filepath, line_number):
|
||||||
|
if filepath not in self.files_with_issues.keys():
|
||||||
|
self.files_with_issues[filepath] = []
|
||||||
|
self.files_with_issues[filepath].append(line_number)
|
||||||
|
|
||||||
def check_file_line(self, filepath, line, line_number):
|
def check_file_line(self, filepath, line, line_number):
|
||||||
if self.issue_with_line(line):
|
if self.issue_with_line(line):
|
||||||
if filepath not in self.files_with_issues.keys():
|
self.record_issue(filepath, line_number)
|
||||||
self.files_with_issues[filepath] = []
|
|
||||||
self.files_with_issues[filepath].append(line_number)
|
|
||||||
|
|
||||||
def output_file_issues(self, logger):
|
def output_file_issues(self, logger):
|
||||||
if self.files_with_issues.values():
|
if self.files_with_issues.values():
|
||||||
|
@ -132,6 +135,27 @@ class TabIssueTracker(IssueTracker):
|
||||||
return b"\t" in line
|
return b"\t" in line
|
||||||
|
|
||||||
|
|
||||||
|
class MergeArtifactIssueTracker(IssueTracker):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.heading = "Merge artifact:"
|
||||||
|
|
||||||
|
def issue_with_line(self, filepath, line):
|
||||||
|
# Detect leftover git conflict markers.
|
||||||
|
if line.startswith(b'<<<<<<< ') or line.startswith(b'>>>>>>> '):
|
||||||
|
return True
|
||||||
|
if line.startswith(b'||||||| '): # from merge.conflictStyle=diff3
|
||||||
|
return True
|
||||||
|
if line.rstrip(b'\r\n') == b'=======' and \
|
||||||
|
not filepath.endswith('.md'):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_file_line(self, filepath, line, line_number):
|
||||||
|
if self.issue_with_line(filepath, line):
|
||||||
|
self.record_issue(filepath, line_number)
|
||||||
|
|
||||||
class TodoIssueTracker(IssueTracker):
|
class TodoIssueTracker(IssueTracker):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -167,6 +191,7 @@ class IntegrityChecker(object):
|
||||||
LineEndingIssueTracker(),
|
LineEndingIssueTracker(),
|
||||||
TrailingWhitespaceIssueTracker(),
|
TrailingWhitespaceIssueTracker(),
|
||||||
TabIssueTracker(),
|
TabIssueTracker(),
|
||||||
|
MergeArtifactIssueTracker(),
|
||||||
TodoIssueTracker(),
|
TodoIssueTracker(),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue