mirror of
https://github.com/Theodor-Springmann-Stiftung/KGPZ.git
synced 2025-10-29 09:05:30 +00:00
Edited custom linter
This commit is contained in:
@@ -26,7 +26,7 @@ def check_references(beitrag_root, reference_data, filepath):
|
|||||||
ref_id = ref.get('ref')
|
ref_id = ref.get('ref')
|
||||||
if ref_id not in reference_data[ref_type]:
|
if ref_id not in reference_data[ref_type]:
|
||||||
line_number = ref.sourceline
|
line_number = ref.sourceline
|
||||||
errors.append((relative_path, line_number, f"INVALID REFERENCE ({ref_type}:{ref_id})"))
|
errors.append(f"{relative_path}, Line {line_number}: INVALID REFERENCE ({ref_type}:{ref_id})")
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -48,15 +48,12 @@ def main():
|
|||||||
errors = check_references(beitrag_root, reference_data, filepath)
|
errors = check_references(beitrag_root, reference_data, filepath)
|
||||||
all_errors.extend(errors)
|
all_errors.extend(errors)
|
||||||
|
|
||||||
all_errors.sort(key=lambda x: (x[0], x[1]))
|
all_errors.sort()
|
||||||
|
|
||||||
with open('linter_results.txt', 'w') as f:
|
|
||||||
for filepath, line_number, error_message in all_errors:
|
|
||||||
f.write(f"{filepath}:{line_number}:{error_message}\n")
|
|
||||||
|
|
||||||
if all_errors:
|
if all_errors:
|
||||||
for filepath, line_number, error_message in all_errors:
|
print("Linter found the following errors:")
|
||||||
print(f"{filepath}, Line {line_number}: {error_message}")
|
for error in all_errors:
|
||||||
|
print(error)
|
||||||
exit(1) # Exit with error code if there are any errors
|
exit(1) # Exit with error code if there are any errors
|
||||||
else:
|
else:
|
||||||
print("No errors found.")
|
print("No errors found.")
|
||||||
|
|||||||
Reference in New Issue
Block a user