1
0
Fork 0

Merge pull request #145 from google/truncate-clang-format

Truncate clang-format comments
This commit is contained in:
Mikhail Goncharov 2020-03-10 12:00:45 +01:00 committed by GitHub
commit 7f5471f2ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -290,6 +290,16 @@ class BuildReport:
diffs = _parse_patch(open(p, 'r')) diffs = _parse_patch(open(p, 'r'))
success = len(diffs) == 0 success = len(diffs) == 0
for d in diffs: for d in diffs:
lines = d['diff'].splitlines(True)
m = 10 # max number of lines to report.
description = 'please reformat the code\n```\n'
n = len(lines)
cut = n > m + 1
if cut:
lines = lines[:m]
description += ''.join(lines) + '\n```'
if cut:
description += '\n{} diff lines are omitted. Please check full report.'.format(n - m)
self.add_lint({ self.add_lint({
'name': 'clang-format', 'name': 'clang-format',
'severity': 'autofix', 'severity': 'autofix',
@ -297,7 +307,7 @@ class BuildReport:
'path': d['filename'], 'path': d['filename'],
'line': d['line'], 'line': d['line'],
'char': 1, 'char': 1,
'description': 'please reformat the code\n```\n' + d['diff'] + '\n```', 'description': description,
}) })
comment = section_title('clang-format', success, present) comment = section_title('clang-format', success, present)
if not success: if not success: