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.
func fun1() (x, y int) {
a, b := 1, 2
b, a = a, b
return a, b
}
func fun2() (x, y int) { // Noncompliant; duplicates fun1
a, b := 1, 2
b, a = a, b
return a, b
}
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.
func fun1() (x, y int) {
a, b := 1, 2
b, a = a, b
return a, b
}
func fun2() (x, y int) { // Intent is clear
return fun1()
}
Exceptions
Functions with fewer than 2 statements are ignored.