max-lines-for-file
Same as max_lines_for_file in Pyramid Lint
- Group
- Complexity
- Path
lint/complexity/max-lines-for-file- Default
- Off, opt in
- Origin
- Pyramid Lint
- Rule
- 261 of 512
Flags a file longer than the configured line limit.
Very long files are hard to navigate and usually mix unrelated responsibilities; splitting them improves readability and review. The rule counts the total lines in the file and reports once, at the top, when the count exceeds the threshold. The diagnostic message states the configured limit.
Options
max-lines (integer, default: 200) — flag files with more than this many
lines.
Invalid
// File exceeds max-lines-for-file threshold (line count > 60)
class ExcessivelyLongFile {
/// Line 5
/// Line 6
/// Line 7
/// Line 8
/// Line 9
/// Line 10
void method1() {}
/// Line 13
/// Line 14
/// Line 15
/// Line 16
/// Line 17
/// Line 18
void method2() {}
/// Line 21
/// Line 22
/// Line 23
/// Line 24
/// Line 25
/// Line 26
void method3() {}
/// Line 29
/// Line 30
/// Line 31
/// Line 32
/// Line 33
/// Line 34
void method4() {}
/// Line 37
/// Line 38
/// Line 39
/// Line 40
/// Line 41
/// Line 42
void method5() {}
/// Line 45
/// Line 46
/// Line 47
/// Line 48
/// Line 49
/// Line 50
void method6() {}
/// Line 53
/// Line 54
/// Line 55
/// Line 56
/// Line 57
/// Line 58
void method7() {}
/// Line 61
/// Line 62
/// Line 63
/// Line 64
/// Line 65
/// Line 66
void method8() {}
/// Line 69
/// Line 70
/// Line 71
/// Line 72
/// Line 73
/// Line 74
void method9() {}
/// Line 77
/// Line 78
/// Line 79
/// Line 80
/// Line 81
/// Line 82
void method10() {}
/// Line 85
/// Line 86
/// Line 87
/// Line 88
/// Line 89
/// Line 90
void method11() {}
/// Line 93
/// Line 94
/// Line 95
/// Line 96
/// Line 97
/// Line 98
void method12() {}
} // File exceeds max-lines-for-file threshold (line count > 60)Valid
// This file stays within the max-lines-for-file threshold (under 60 lines)
class ReasonablySizedFile {
/// A normal sized file
void method1() {
print('method 1');
}
void method2() {
print('method 2');
}
void method3() {
print('method 3');
}
void method4() {
print('method 4');
}
void method5() {
print('method 5');
}
void method6() {
print('method 6');
}
void method7() {
print('method 7');
}
void method8() {
print('method 8');
}
void method9() {
print('method 9');
}
void method10() {
print('method 10');
}
}
// This file is well under the 60-line limit
// It demonstrates good file structure with reasonable number of methods
// and is not overly complex or monolithicConfigure max-lines-for-file
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"complexity": {
"max-lines-for-file": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/complexity/max-lines-for-file: <reason>More complexity rules
- max-lines-for-function
max_lines_for_functionFlags a function or method longer than the configured line limit.
- max-parameters-for-function
max_parameters_for_functionFlags callable declarations and function types with more than the configured number of parameters.
- max-statements
Reports function bodies with too many statements.
- max-switch-cases
max_switch_casesFlags a
switchstatement with more than the configured number of cases. - maximum-nesting-level
maximum_nesting_levelFlags a function whose control-flow nesting runs deeper than the configured level.
- no-boolean-literal-compare
no-boolean-literal-comparerecommendedDon't compare boolean values to boolean literals.
- one-member-abstracts
one_member_abstractsFlags abstract classes whose only member is a single abstract method.
- prefer-conditional-assignment
prefer_conditional_assignmentrecommendedFlags
if (x == null) { x = y; }with no else branch.