2020-06-30 12:49:37 +02:00
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.
== Noncompliant Code Example
----
function calculateCode() {
doTheThing();
doOtherThing();
return code;
}
function getName() { // Noncompliant
doTheThing();
doOtherThing();
return code;
}
----
== Compliant Solution
----
function calculateCode() {
doTheThing();
doOtherThing();
return code;
}
function getName() {
return calculateCode();
}
----
== Exceptions
Functions with fewer than 3 lines are ignored.
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]