mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-17 18:25:42 +02:00
[eric] linter: the file-size debt is reported (82 grandfathered oversized files, top offenders named) instead of hiding behind the enforcement zero
This commit is contained in:
+15
-5
@@ -47,6 +47,7 @@ def run_checks(root: Path) -> tuple[list[str], list[str], list[str], list[str],
|
|||||||
max_items: int = rules["max-folder-items"]
|
max_items: int = rules["max-folder-items"]
|
||||||
check_imports: bool = rules.get("no-nested-imports", False)
|
check_imports: bool = rules.get("no-nested-imports", False)
|
||||||
structural_errors: list[str] = []
|
structural_errors: list[str] = []
|
||||||
|
grandfathered_oversize: list[str] = []
|
||||||
|
|
||||||
file_lines_on = enabled.get("max-file-lines", True)
|
file_lines_on = enabled.get("max-file-lines", True)
|
||||||
folder_items_on = enabled.get("max-folder-items", True)
|
folder_items_on = enabled.get("max-folder-items", True)
|
||||||
@@ -77,13 +78,15 @@ def run_checks(root: Path) -> tuple[list[str], list[str], list[str], list[str],
|
|||||||
if is_excluded(fp, root, excludes):
|
if is_excluded(fp, root, excludes):
|
||||||
continue
|
continue
|
||||||
rel_file = str(fp.relative_to(root))
|
rel_file = str(fp.relative_to(root))
|
||||||
if (
|
# Debt counts only config-grandfathered files (ours, deferred); .lintignore is vendored/generated code and stays out of both numbers.
|
||||||
file_lines_on
|
if file_lines_on and not is_lintignored(fp, root, "max-file-lines", ignores):
|
||||||
and not is_excepted(rel_file, "max-file-lines", exceptions)
|
p_grandfathered = is_excepted(rel_file, "max-file-lines", exceptions)
|
||||||
and not is_lintignored(fp, root, "max-file-lines", ignores)
|
|
||||||
):
|
|
||||||
result = check_file_lines(fp, root, max_lines)
|
result = check_file_lines(fp, root, max_lines)
|
||||||
if result:
|
if result:
|
||||||
|
if p_grandfathered:
|
||||||
|
# Debt is counted even where the gate is silenced: 82 of 102 oversized files were invisible because the exception list hid them from the tally too (ENG-192).
|
||||||
|
grandfathered_oversize.append(rel_file)
|
||||||
|
else:
|
||||||
structural_errors.append(result[0])
|
structural_errors.append(result[0])
|
||||||
if (
|
if (
|
||||||
nested_imports_on
|
nested_imports_on
|
||||||
@@ -93,6 +96,13 @@ def run_checks(root: Path) -> tuple[list[str], list[str], list[str], list[str],
|
|||||||
):
|
):
|
||||||
structural_errors.extend(check_nested_imports(fp, root))
|
structural_errors.extend(check_nested_imports(fp, root))
|
||||||
|
|
||||||
|
if grandfathered_oversize:
|
||||||
|
# The debt line, not a gate: the enforcement number alone made 82 silenced oversized files read as a clean repo.
|
||||||
|
print(f"structural: NOTE {len(grandfathered_oversize)} grandfathered file(s) over {max_lines} lines (debt, not enforced); largest offenders:", flush=True)
|
||||||
|
p_sized = sorted(((sum(1 for _ in open(root / f, errors='ignore')), f) for f in grandfathered_oversize), reverse=True)
|
||||||
|
for p_n, p_f in p_sized[:5]:
|
||||||
|
print(f" {p_f}: {p_n} lines", flush=True)
|
||||||
|
|
||||||
vulture_errors: list[str] = []
|
vulture_errors: list[str] = []
|
||||||
if enabled.get("vulture", True):
|
if enabled.get("vulture", True):
|
||||||
vulture_confidence = rules.get("vulture-min-confidence")
|
vulture_confidence = rules.get("vulture-min-confidence")
|
||||||
|
|||||||
Reference in New Issue
Block a user