Skip to content

Add file length CI check (500-line limit)#149

Merged
Miyamura80 merged 3 commits intomainfrom
ci/file-length-check
Mar 25, 2026
Merged

Add file length CI check (500-line limit)#149
Miyamura80 merged 3 commits intomainfrom
ci/file-length-check

Conversation

@Miyamura80
Copy link
Owner

Summary

  • Adds a Python file length check (make file_len_check) that enforces a 500-line maximum, preventing AI-generated code from becoming monolithic
  • Configurable via [tool.file_length] in pyproject.toml with an exclude list for justified exceptions (currently onboard.py at 655 lines)
  • Integrated into make ci and the linter GitHub Actions workflow
  • Includes a Cursor rule (.cursor/rules/file_length.mdc) documenting the rationale and refactoring guidance

Test plan

  • make file_len_check passes with onboard.py excluded
  • Verified onboard.py (655 lines) would be caught without the exclusion
  • CI workflow runs the check successfully

🤖 Generated with Claude Code

Adds a 500-line limit on Python files enforced via `make file_len_check`
(included in `make ci`) and the linter GitHub Actions workflow. Files
exceeding the limit can be added to [tool.file_length] exclude in
pyproject.toml. Includes a Cursor rule documenting the rationale.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR introduces a Python file-length enforcement check (make file_len_check) that fails CI when any .py file exceeds 500 lines, with an opt-out exclude list in pyproject.toml. The check is cleanly integrated into both the make ci target and the GitHub Actions linter workflow.

The implementation is well-structured:

  • Directory skipping is correct — root-level dirs are filtered via parts[0], nested cache dirs via parts[:-1]
  • Exclusion matching uses rel.as_posix() (previously-flagged Windows path bug is already resolved)
  • Config loading has sensible defaults if [tool.file_length] is absent
  • The script follows the project's coding style (uppercase constants, built-in generic types, from __future__ import annotations)

No issues found. The previously flagged as_posix() and PurePosixPath concerns have both been addressed.

Confidence Score: 5/5

  • Safe to merge — the check is additive, non-breaking, and already passes with the existing codebase.
  • All previously flagged issues are resolved, the logic is correct across all identified edge cases, and the integration is consistent with the existing CI setup. No outstanding concerns.
  • No files require special attention.

Important Files Changed

Filename Overview
scripts/check_file_length.py New script that reads config from pyproject.toml, walks repo .py files skipping relevant cache/vendor directories, and reports files exceeding the configured line limit. Previously-flagged cross-platform path issues (as_posix(), Path annotation) are already resolved.
pyproject.toml Adds [tool.file_length] section with max_lines = 500 and onboard.py excluded; straightforward config addition consistent with the existing vulture exclude list.
.github/workflows/linter_require_ruff.yaml Appends the file-length check as a new workflow step; consistent with existing step style in the file.
Makefile Adds file_len_check target and wires it into the ci target; the updated help comment accurately reflects the new dependency.
.cursor/rules/file_length.mdc Cursor rule documenting the 500-line limit rationale and how to add exclusions; accurate and consistent with the implementation.

Reviews (3): Last reviewed commit: "⚙️ remove refactoring guidance from curs..." | Re-trigger Greptile

Miyamura80 and others added 2 commits March 25, 2026 00:07
- Use pathlib.Path instead of PurePosixPath in type annotation
- Use rel.as_posix() for exclude matching to handle Windows paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Miyamura80 Miyamura80 merged commit 56733d4 into main Mar 25, 2026
11 checks passed
@github-actions github-actions bot deleted the ci/file-length-check branch March 25, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant