Skip to content

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.

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.

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.

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.

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.
Good

The 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.

  • 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