Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 1.93 KB

File metadata and controls

77 lines (55 loc) · 1.93 KB

structure.pass-through-wrappers

Flags trivial wrappers that mostly just rename or forward another call.

  • Family: structure
  • Severity: strong
  • Scope: file
  • Requires: file.functionSummaries, file.comments

How it works

The rule looks for functions whose body is essentially a direct pass-through call. It skips two common intentional cases:

  • nearby alias / compatibility comments such as alias or backward compatibility
  • boundary wrappers around targets like fetch, axios.*, prisma.*, redis.*, and similar APIs

Flagged example

export function getUser(id: string) {
  return loadUser(id);
}

export function saveUser(input: UserInput) {
  return persistUser(input);
}

Usually ignored

// backward compatibility alias
export function fetchUserRecord(id: string) {
  return getUser(id);
}

export function getJson(url: string) {
  return fetch(url);
}

How to fix / do this better

A wrapper should earn its existence. Keep it only if it adds something real, such as:

  • validation
  • normalization
  • retries or metrics
  • naming a stable compatibility layer
  • adapting one API shape into another

Otherwise, call the underlying function directly or merge the wrapper away.

export async function saveUser(input: UserInput) {
  const normalized = normalizeUserInput(input);
  return persistUser(normalized);
}

The goal is to reduce indirection that makes the codebase feel larger without adding behavior or clearer boundaries.

Scoring

Each wrapper adds 2 points, capped at 5 for the file.

Benchmark signal

Small pinned rule benchmark (manifest):

  • Signal rank: #6 of 9
  • Signal score: 0.67 / 1.00
  • Best separating metric: findings / file (0.85)
  • Hit rate: 5/6 AI repos vs 4/5 mature OSS repos
  • Full results: rule signal report