Pass-through wrapper
This is how the comment reads inline, under the flagged line.
Why it matters
A function that only forwards its arguments adds a name to learn and a hop to follow, and hides nothing. Ousterhout calls this a shallow module.
What to do
Delete it and call the inner function. Keep a wrapper only when it adds a real decision or hides a detail.
Examples
export function getUser(id) {
return db.getUser(id);
}// callers use db.getUser(id) directly
What it catches
It reads the shape of the code: functions, blocks, loops and calls. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
export function getUser(id) {
return db.getUser(id);
}
const load = (a, b) => fetchAll(a, b);
src/app.py
def get_user(uid):
return db.get_user(uid)
Left alone
export function getUser(id) {
return db.getUser(id, { cache: true });
}
src/app.py
def get_user(uid):
return db.get_user(str(uid))
Research
Functions that only forward their arguments to another function. They add a name to learn and hide nothing.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"pass-through"
],
"severity": {
"pass-through": "low"
}
}
}
getUseronly forwards its arguments todb.getUser. Callers could calldb.getUserdirectly.