avoid-long-functions
added in: 1.2.0
warning
Long blocks of code are difficult to reuse and understand because they are usually responsible for more than one thing. Separating those to several short ones with proper names helps you reuse your code and understand it better without reading the whole function body.
Use ignored-names
configuration (default is build
), if you want to ignore specific function / method names.
Use max-length
configuration (default is 50
), to set up the line length number after which the rule should trigger.
⚙️ Config example
dart_code_metrics:
...
rules:
...
- avoid-long-functions:
max-length: 80
ignored-names:
- some
- name
Example
❌ Bad:
void someLongFunction(...) { // LINT
...
}
✅ Good:
void someFunction() {
firstMovedOutFunction();
secondMovedOutFunction();
...
}
void firstMovedOutFunction() {
...
}
void secondMovedOutFunction() {
...
}