Skip to content

ALL-FUNC0004 · unnecessary_one_line_concrete_function

Find one-line nested functions whose named boundary lacks demonstrated reuse.

This is a deterministic rule for all languages. Read its implementation.

Inspect nested functions whose complete reference scope is statically visible. Omit an optional docstring and count nonblank, non-comment physical lines in the executable body. Report a concrete nested function with exactly one implementation line when direct calls remain below minimum_references, which defaults to two. Public module functions and methods remain public boundaries because repository references cannot disprove external callers or dynamic dispatch.

Each finding identifies the definition, structural role, one-line measurement, project reference count, and every matching reference location. The result value is the number of shallow concrete boundaries that lack the configured reuse evidence.

Properties, abstract methods, Protocol contracts, overloaded APIs and implementations, special methods, recursion, pass or ellipsis bodies, and NotImplementedError placeholders are excluded. A nested function passed as a first-class callable is retained because it cannot be replaced by its expression. Functions meeting the reuse threshold remain as named boundaries. ALL-FUNC0002 exclusively owns private module helpers, while Vulture owns unused private functions.

A nested normalize called once and containing only return value.strip() is reported even when a long docstring precedes the return. The same function used at two call sites is accepted. A callback passed to map, public API, one-line property, abstract method, or overload implementation is accepted regardless of visible repository reuse.

  • Cites “Refactoring”, Inline Function. Open reference
  • Cites “A Philosophy of Software Design”, chapter 4, deep and shallow modules
  • Cites “The Python Language Reference”, special method names. Open reference
  • Cites “Python typing specification”, Protocols. Open reference
  • Cites “Python typing specification”, overloads. Open reference