Two functions having the same implementation are suspicious. It might be that something else was intended. Or the duplication is intentional, which becomes a maintenance burden.
function calculateCode() {
doTheThing();
doOtherThing();
return code;
}
function getName() { // Noncompliant: duplicates calculateCode
doTheThing();
doOtherThing();
return code;
}
If the identical logic is intentional, the code should be refactored to avoid duplication. For example, by having both functions call the same function or by having one implementation invoke the other.
function calculateCode() {
doTheThing();
doOtherThing();
return code;
}
function getName() { // Intent is clear
return calculateCode();
}
list.map((item) => ({
name: item.name,
address: item.address,
country: item.country
}));