Merge pull request #145 from google/truncate-clang-format
Truncate clang-format comments
This commit is contained in:
commit
7f5471f2ba
1 changed files with 11 additions and 1 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue