1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-22 09:27:39 +00:00

Create more work for myself

This ensures no lines start with an empty line, and all files finish
with exactly one "\n".
This commit is contained in:
SquidDev
2020-05-11 16:08:23 +01:00
parent 6b3773a862
commit 156023b154
34 changed files with 15 additions and 37 deletions

View File

@@ -10,8 +10,13 @@ for path in pathlib.Path("src").glob("**/*"):
continue
with path.open(encoding="utf-8") as file:
has_dos, has_trailing, needs_final = False, False, False
has_dos, has_trailing, first, count = False, False, 0, True
for i, line in enumerate(file):
if first:
first = False
if line.strip() == "":
print("%s has empty first line" % path)
if len(line) >= 2 and line[-2] == "\r" and line[-1] == "\n" and not has_line:
print("%s has contains '\\r\\n' on line %d" % (path, i + 1))
problems = has_dos = True
@@ -20,8 +25,15 @@ for path in pathlib.Path("src").glob("**/*"):
print("%s has trailing whitespace on line %d" % (path, i + 1))
problems = has_trailing = True
if line is not None and len(line) >= 1 and line[-1] != "\n":
print("%s should end with '\\n'" % path)
if len(line) == 0 or line[-1] != "\n":
count = 0
elif line.strip() == "":
count += 1
else:
count = 1
if count != 1:
print("%s should have 1 trailing lines, but has %d" % (path, count))
problems = True
if problems: