ALL-FUNC0002 · single_use_trivial_helper
Detect a private one-line helper with only one local reference.
This is a deterministic rule for all languages. Read its implementation.
Definition
Section titled “Definition”Inspect undecorated private functions declared directly at module scope. After omitting an
optional docstring, require exactly one non-pass, non-raise statement, no more than
maximum_lines executable lines, and exactly one loaded reference outside the function body
in the same module. The Boolean result reports whether this function is a candidate.
Evidence
Section titled “Evidence”Each finding identifies the helper definition and its only local reference. The rule does not edit code because inlining can change evaluation order, exception location, or debugging.
Exceptions
Section titled “Exceptions”Public functions, methods, nested functions, decorated hooks, callbacks, fixtures, overloads,
protocol implementations, recursive helpers, unused functions, and helpers with multiple
references are excluded structurally. ignore_names retains a deliberate named boundary.
Vulture remains responsible for functions with no uses.
Examples
Section titled “Examples”Bad
`_normalize = lambda` is not required. An undecorated `_normalize` whose body is only`return value.strip()` and which is called once is reported for possible inlining.
GoodThe same helper called from three sites remains. A decorated one-line route handler, a public
adapter, and a multiline expression with one top-level return are not candidates.
References
Section titled “References”- Cites “A Philosophy of Software Design”, chapter 4, shallow modules
- Cites “Clean Code”, chapter 3, small functions
- Cites “Vulture documentation”, unused code boundary. Open reference