scripts: ci: check_compliance: KeepSorted allow combining strip and re

No reason we couldn't strip a line we want to match to a regex.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2025-07-22 08:33:03 +02:00 committed by Chris Friedt
parent 42640b19d5
commit b1f398d176

View File

@ -1884,6 +1884,9 @@ class KeepSorted(ComplianceTest):
# Ignore blank lines
continue
if strip is not None:
line = line.strip(strip)
if regex:
# check for regex
if not re.match(regex, line):
@ -1892,9 +1895,6 @@ class KeepSorted(ComplianceTest):
if _test_indent(line):
continue
if strip is not None:
line = line.strip(strip)
if fold:
# Fold back indented lines after the current one
for cont in takewhile(_test_indent, lines[idx + 1:]):
@ -1918,8 +1918,8 @@ class KeepSorted(ComplianceTest):
start_marker = f"{self.MARKER}-start"
stop_marker = f"{self.MARKER}-stop"
regex_marker = r"re\((.+)\)"
strip_marker = r"strip\((.+)\)"
regex_marker = r"re\(([^)]+)\)"
strip_marker = r"strip\(([^)]+)\)"
nofold_marker = "nofold"
start_line = 0
regex = None