Skip to content

A one-line helper used once ​

Code nobody needs: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as single-use.

What makes a one-line helper used once a bad practice? ​

The standards that call it a bad practice: Fowler: Inline Function; Anthropic's prompting guide: "Don't create helpers, utilities, or abstractions for one-time operations".

What does lessloc do about a one-line helper used once? ​

lessloc catches it as single-use.

  • single-use (tier 2): A one-line helper used once.

Examples ​

Caught as single-use:

python
def _label(o):
    return o.name.upper()


def report(orders):
    return [_label(o) for o in orders]

Written well:

python
def report(orders):
    return [o.name.upper() for o in orders]

The other patterns in Code nobody needs:

Released under the Apache-2.0 license. · llms.txt