mirror of
https://github.com/open-goal/jak-project
synced 2026-06-08 20:29:54 -04:00
ci: check for incorrect assert usage in C++ files (#2461)
This commit is contained in:
@@ -35,3 +35,6 @@ jobs:
|
||||
|
||||
- name: Check for Unresolved Conflicts
|
||||
run: python ./scripts/gsrc/check-for-conflicts.py
|
||||
|
||||
- name: Check for Incorrect Asserts
|
||||
run: python ./scripts/ci/check-for-asserts.py
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import glob
|
||||
import re
|
||||
|
||||
folders_to_check = ["common", "decompiler", "game", "goalc", "test", "tools", "lsp"]
|
||||
|
||||
flagged_instances = []
|
||||
|
||||
for folder in folders_to_check:
|
||||
files_to_check = glob.glob("./{}/**/*.cpp".format(folder), recursive=True)
|
||||
files_to_check += glob.glob("./{}/**/*.h".format(folder), recursive=True)
|
||||
for filename in files_to_check:
|
||||
# Get the file contents
|
||||
with open(filename, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
for i, line in enumerate(lines):
|
||||
results = re.findall(r"\bassert\(", line)
|
||||
if len(results) > 0:
|
||||
flagged_instances.append(filename + ":" + str(i + 1))
|
||||
|
||||
if len(flagged_instances) == 0:
|
||||
exit(0)
|
||||
|
||||
print("Found asserts in the following files:")
|
||||
for file in flagged_instances:
|
||||
print(file)
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user