Functions should not have identical implementations

There are rules such as this Java static code analysis: All branches in a conditional structure should not have exactly the same implementation that will find identical branches in control structures.

In light of just having been made aware of a bug (written by yours truly :upside_down_face: ) where three functions have the same implementation due to non diligent use of copy paste, I thought it would be a good idea to make a post about this.

It is likely a bug if functions have exactly the same implementation. Maybe if the function body consists of only one function call there could be an argument to allow duplicates from a readability standpoint.

Functions whose bodies are non-trivial that differ at most by the name of local variables, including parameters are candidates for non-conformance for this rule.

Maybe it’s worth considering this rule on a per-class basis. Member functions of different classes could conceivably have the same implementation, especially in terms of using member functions/variables that are not public. However, if functions on the same class are more likely to be subject to this rule.