-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
What it does
Checks for functions which are only called in 1 location.
Enabling this lint can guard against segmentation which can occur stealthily over a long period of development, when a function is split purposefully for testing or readability this lint can be allowed for these specific cases.
Advantage
Functions that are only called once, may be better suited as scopes or in-lined.
Premature abstraction can occur in development leading to segmentation with many small functions that are only called once, this can introduce significant additional complexity and indirection that makes the code-base less readable.
Drawbacks
It can be useful to split a large function into sub-functions even when these are only called once each, this can improve test-ability and readability. This is often done purposefully.
Example
fn main() {
one();
}
fn one() {
// [...]
}
Could be written as:
fn main() {
// [...]
}