mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-07-04 18:23:06 +02:00
Add scripts/check_file_length.py and a max-file-length pre-commit hook that fails any Python/shell file exceeding 400 lines. Extract UIWidgetsMixin and UIFlowsRelaxedMixin from screen_lock.py and _ui_flows.py respectively, and split 6 oversized test files into part2/part3/part4 siblings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
736 B
Python
28 lines
736 B
Python
#!/usr/bin/env python3
|
|
"""Pre-commit hook: fail if any file exceeds MAX_LINES lines."""
|
|
|
|
import sys
|
|
|
|
MAX_LINES = 400
|
|
|
|
|
|
def main() -> int:
|
|
"""Return 1 if any file exceeds the line limit, else 0."""
|
|
failed = False
|
|
for filepath in sys.argv[1:]:
|
|
try:
|
|
with open(filepath, encoding="utf-8", errors="replace") as fh:
|
|
count = sum(1 for _ in fh)
|
|
except OSError as exc:
|
|
print(f"ERROR reading {filepath}: {exc}", file=sys.stderr)
|
|
failed = True
|
|
continue
|
|
if count > MAX_LINES:
|
|
print(f"{filepath}: {count} lines (max {MAX_LINES})")
|
|
failed = True
|
|
return 1 if failed else 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|