mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 03:20:05 +01:00
CI: check for empty lines between closing braces
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1190>
This commit is contained in:
parent
546debe926
commit
436eb42044
1 changed files with 12 additions and 0 deletions
|
|
@ -48,6 +48,17 @@ def test_trailing_whitespace(lines: list[str]) -> list[WhitespaceError]:
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
def test_empty_line_between_braces(lines: list[str]) -> list[WhitespaceError]:
|
||||||
|
errors = []
|
||||||
|
for idx in range(len(lines) - 3):
|
||||||
|
l1 = lines[idx]
|
||||||
|
l2 = lines[idx + 1]
|
||||||
|
l3 = lines[idx + 2]
|
||||||
|
if l1.strip() == "}" and l3.strip() == "}" and l2.strip() == "":
|
||||||
|
errors.append(WhitespaceError("Empty line between closing braces", idx + 1))
|
||||||
|
return errors
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Whitespace checker script")
|
parser = argparse.ArgumentParser(description="Whitespace checker script")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
@ -78,6 +89,7 @@ def main():
|
||||||
if any(file.name.endswith(suffix) for suffix in [".c", ".h"]):
|
if any(file.name.endswith(suffix) for suffix in [".c", ".h"]):
|
||||||
if not file.parts[0] == "include":
|
if not file.parts[0] == "include":
|
||||||
errors.extend(test_duplicate_empty_lines(lines))
|
errors.extend(test_duplicate_empty_lines(lines))
|
||||||
|
errors.extend(test_empty_line_between_braces(lines))
|
||||||
|
|
||||||
for e in errors:
|
for e in errors:
|
||||||
print(f"{red}ERROR: {e.message} in {file}:{reset}", file=sys.stderr)
|
print(f"{red}ERROR: {e.message} in {file}:{reset}", file=sys.stderr)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue