Skip to content

Commit dd96a9b

Browse files
committed
scripts: ci: check_compliance: Add support for end line and column
Reporting or annotating issues can be done on a range rather than a single line. Add support for end line and end column. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent f537cf3 commit dd96a9b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

scripts/ci/check_compliance.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,25 @@ def get_files(filter=None, paths=None):
8282
return files
8383

8484
class FmtdFailure(Failure):
85-
86-
def __init__(self, severity, title, file, line=None, col=None, desc=""):
85+
def __init__(
86+
self, severity, title, file, line=None, col=None, desc="", end_line=None, end_col=None
87+
):
8788
self.severity = severity
8889
self.title = title
8990
self.file = file
9091
self.line = line
9192
self.col = col
93+
self.end_line = end_line
94+
self.end_col = end_col
9295
self.desc = desc
9396
description = f':{desc}' if desc else ''
9497
msg_body = desc or title
9598

9699
txt = f'\n{title}{description}\nFile:{file}' + \
97100
(f'\nLine:{line}' if line else '') + \
98-
(f'\nColumn:{col}' if col else '')
101+
(f'\nColumn:{col}' if col else '') + \
102+
(f'\nEndLine:{end_line}' if end_line else '') + \
103+
(f'\nEndColumn:{end_col}' if end_col else '')
99104
msg = f'{file}' + (f':{line}' if line else '') + f' {msg_body}'
100105
typ = severity.lower()
101106

@@ -172,13 +177,15 @@ def failure(self, text, msg=None, type_="failure"):
172177
fail = Failure(msg or f'{type(self).name} issues', type_)
173178
self._result(fail, text)
174179

175-
def fmtd_failure(self, severity, title, file, line=None, col=None, desc=""):
180+
def fmtd_failure(
181+
self, severity, title, file, line=None, col=None, desc="", end_line=None, end_col=None
182+
):
176183
"""
177184
Signals that the test failed, and store the information in a formatted
178185
standardized manner. Can be called many times within the same test to
179186
report multiple failures.
180187
"""
181-
fail = FmtdFailure(severity, title, file, line, col, desc)
188+
fail = FmtdFailure(severity, title, file, line, col, desc, end_line, end_col)
182189
self._result(fail, fail.text)
183190
self.fmtd_failures.append(fail)
184191

@@ -1696,6 +1703,8 @@ def annotate(res):
16961703
notice = f'::{res.severity} file={res.file}' + \
16971704
(f',line={res.line}' if res.line else '') + \
16981705
(f',col={res.col}' if res.col else '') + \
1706+
(f',endLine={res.end_line}' if res.end_line else '') + \
1707+
(f',endColumn={res.end_col}' if res.end_col else '') + \
16991708
f',title={res.title}::{msg}'
17001709
print(notice)
17011710

0 commit comments

Comments
 (0)