Skip to content

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

Open
Miyamura80 wants to merge 2 commits intomainfrom
ci/file-length-check
Open

Add file length CI check (500-line limit)#149
Miyamura80 wants to merge 2 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 adds a Python file-length CI check that enforces a 500-line maximum across the codebase, with a configurable exclude list in pyproject.toml. The check is wired into both make ci and the existing linter GitHub Actions workflow, and is documented with a Cursor rule.

  • scripts/check_file_length.py — new script that reads config from [tool.file_length] in pyproject.toml, skips virtual-env/cache directories, and exits non-zero when any file exceeds max_lines
  • pyproject.toml — adds the [tool.file_length] section; onboard.py (655 lines) is pre-excluded, matching the existing vulture exclusion
  • Makefile — new file_len_check target (with check_uv prerequisite) added to ci
  • .github/workflows/linter_require_ruff.yaml — step added to run the script directly, consistent with how check_ai_writing.py is invoked in the same workflow
  • .cursor/rules/file_length.mdc — documents the limit, rationale, and how to add justified exclusions

Previous review concerns (cross-platform path matching via rel.as_posix() and the type annotation) have both been addressed in the current revision. The implementation is clean and the exclusion format (full relative path, e.g. "onboard.py" for a root-level file) is self-consistent.

Confidence Score: 5/5

  • This PR is safe to merge — it adds a new enforcement check with no risk to existing functionality.
  • The script is straightforward and well-guarded (directory skips, configurable exclusions, cross-platform path handling with rel.as_posix()). The previous reviewer concerns have been fully addressed. The integration into both make ci and the GitHub Actions workflow is consistent with existing patterns in the repo. No logic errors or regressions identified.
  • No files require special attention.

Important Files Changed

Filename Overview
scripts/check_file_length.py New script that enforces the 500-line limit by reading config from pyproject.toml and walking the repo. Previous concerns about str(rel) vs rel.as_posix() and the type annotation have been addressed. Logic is correct.
Makefile Adds file_len_check target with check_uv prerequisite and wires it into ci. Comment on the ci target is updated to mention the new check.
pyproject.toml Adds [tool.file_length] section with max_lines = 500 and onboard.py in the exclude list, consistent with the existing [tool.vulture] exclusion.
.github/workflows/linter_require_ruff.yaml Adds a "Run file length check" step that invokes the script directly, consistent with how check_ai_writing.py is called in the same workflow.
.cursor/rules/file_length.mdc New Cursor rule documenting the 500-line limit, its rationale, refactoring guidance, and the pyproject.toml exclude format.

Reviews (2): Last reviewed commit: "🐛 address PR review feedback: cross-pla..." | Re-trigger Greptile

- 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>
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