duplicate-code-block
the same block of code written out in two or more files
The argument
Duplicated Patterns & Logic
The same pattern in 2+ files gets extracted to the lowest common ancestor common/ (loading/error state handling, validation logic, repeated transformations, generic named constants like a SortDirection union belong in src/common/constants/).
The composition remedy is never duplication. A class that holds a shared collaborator and forwards to it through one-line methods (update() { return this.runState.update(...) }) repeats that shape in every class holding the same collaborator — by design: it is what the class-inheritance rule mandates in place of extends (see the thin-wrapper rule's carve-out). Both duplication tiers skip it.
The proof
interface Params {
charges: Array<{ active: boolean; pending: boolean; amount: number; multiplier: number; bonus: number; fee: number; penalty: number }>;
}
export const totalCharges = ({ charges }: Params): number => {
let total = 0;
for (const charge of charges) {
if (charge.active && charge.amount > 0) {
total += charge.amount * charge.multiplier + charge.bonus;
} else if (charge.pending) {
total += charge.amount / 2 - charge.fee;
} else {
total -= charge.penalty;
}
}
return total * 100;
};
interface Params {
charges: Array<{ amount: number; multiplier: number }>;
}
export const totalCharges = ({ charges }: Params): number => {
return charges.reduce((total, charge) => total + charge.amount * charge.multiplier, 0);
};
Its numbers
The defaults the pack ships. A repo may set its own.
- minTokens
- 50
{
"standards-checks": {
"duplicate-code-block": {
"settings": {
"minTokens": 50
}
}
}
}Turn it down
Both lines go in your lightsout.config.json.
"standards-checks": { "duplicate-code-block": "advisory" }"standards-checks": { "duplicate-code-block": "off" }