duplicate-function-body
two functions with the same body under different variable names
Deterministic checkblocking by defaultbasecode
The argument
This rule states its summary and proves it with an example.
The proof
fail
interface Params {
id: number;
totals: Record<string, number>;
}
export const buildChargeSummary = ({ id, totals }: Params): Record<string, number> => {
const first = totals.a + totals.b + totals.c + totals.d;
const second = first + totals.e + totals.f + totals.g + totals.h;
const third = second + totals.i + totals.j + totals.k + totals.l;
return { id, first, second, third };
};
pass
interface Params {
id: number;
totals: Record<string, number>;
}
export const buildChargeSummary = ({ id, totals }: Params): Record<string, number> => {
const first = totals.a + totals.b + totals.c + totals.d;
const second = first + totals.e + totals.f + totals.g + totals.h;
const third = second + totals.i + totals.j + totals.k + totals.l;
return { id, first, second, third };
};
Its numbers
The defaults the pack ships. A repo may set its own.
- minBodyTokens
- 40
{
"standards-checks": {
"duplicate-function-body": {
"settings": {
"minBodyTokens": 40
}
}
}
}Turn it down
Both lines go in your lightsout.config.json.
"standards-checks": { "duplicate-function-body": "advisory" }"standards-checks": { "duplicate-function-body": "off" }