When two functions have the same implementation, either it was a mistake - something else was intended - or the duplication was intentional, but may be confusing to maintainers. In the latter case, the code should be refactored. Numerical and string literals are not taken into account.
class MyClass {
private readonly CODE = "bounteous";
public calculateCode(): string {
doTheThing();
doOtherThing();
return this.CODE;
}
public getName(): string { // Noncompliant
doTheThing();
doOtherThing();
return this.CODE;
}
}
class MyClass {
private readonly CODE = "bounteous";
public calculateCode(): string {
doTheThing();
doOtherThing();
return this.CODE;
}
public getName(): string {
return this.calculateCode();
}
}
Functions with fewer than 3 lines are ignored.