File must have at most max_lines lines, using the same accounting as file_min_lines. Catches the everything-module anti-pattern — a lib.rs / index.ts / helpers.py that grew unbounded.
Choosing a limit: set it just above the largest file you accept today, as a ratchet rather than an ideal, and lower it as modules get split. Scope it to hand-written sources (paths: "src/**/*.rs") and leave out lockfiles, generated code, fixtures and vendored files, which are long by nature. A warning level suits an advisory size budget; an error suits a hard cap.
Lines and bytes are different budgets: a minified bundle can be one enormous line, which file_max_lines passes. Pair it with file_max_size when the concern is repository weight rather than readability.
Options
Section titled "Options"| Option | Type | Required | Default | Description |
|---|---|---|---|---|
max_lines | integer (>= 0) | yes | Maximum allowed line count. |
Plus the common paths, level, id, when, scope_filter, and expect_matches fields. This table is generated from the JSON Schema; option types and defaults are authoritative.
Example
Section titled "Example"A source file over the line cap
Section titled "A source file over the line cap"The rule fires on this repository:
- src/
- src/bloated.rs
⚠ warning cap-source-file
file has 7 line(s); at most 5 allowed
- src/tiny.rs✓
fn a() {}fn b() {}fn c() {}fn d() {}fn e() {}fn f() {}fn g() {}fn a() {}With this .alint.yml:
version: 1rules: - id: cap-source-file kind: file_max_lines paths: "src/**/*.rs" max_lines: 5 level: warningalint check reports:
--- src/bloated.rs ------------------------------------------------------------- ! warning cap-source-file file has 7 line(s); at most 5 allowed
Summary (1 violation): ! 1 warning 0 passing * 1 failingA source file within the line cap
Section titled "A source file within the line cap"This repository is compliant:
- src/
- src/medium.rs✓
- src/tiny.rs✓
fn a() {}fn b() {}fn c() {}fn d() {}fn e() {}fn a() {}With this .alint.yml:
version: 1rules: - id: cap-source-file kind: file_max_lines paths: "src/**/*.rs" max_lines: 5 level: warningalint check reports:
v All 1 rule(s) passed.