Skip to content

ALL-FUNC0006 · shallow_callable

Detect a one-line public callable with no behavior or reuse.

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

Inspect undocumented public Python module functions after removing an optional docstring. Report a callable with one physical implementation line when it contains fewer than minimum_operations behavior operations and has fewer than minimum_references project references. The default requires one operation. Behavior operations include calls, comparisons, boolean and arithmetic expressions, comprehensions, conditional expressions, assignment expressions, awaiting, and yielding.

Each finding records the physical implementation line count, behavior operation count, project reference count, complete source range, and sole statement kind. The rule measures reference loads by name, so it can conservatively miss a method when unrelated classes reuse the same method name. ALL-FUNC0005 separately owns exact unary forwarding wrappers.

Private helpers, nested functions, methods, stubs, tests, and documented public boundaries remain owned by their focused rules. Protocol, abstract, overload, framework lifecycle, and structurally proven polymorphic functions are excluded. Configure ignore_names only for a required external boundary that cannot express more behavior.

Bad

`answer` only returns a literal and nothing reaches it. Its public boundary adds no behavior or
demonstrated reuse.
Good

accepts calls inspect.isfunction(candidate), so its one return statement performs a real operation. A small parser reused from several project sites can also retain its named boundary.

  • Cites “Refactoring”, Inline Function. Open reference
  • Cites “A Philosophy of Software Design”, chapter 4, deep and shallow modules
  • Cites “Clean Code”, chapter 3, function abstraction levels