Details
-
Type:
Code Smell Detection
-
Status: Closed
-
Resolution: Duplicate
-
Labels:
-
Message:
-
List of parameters:
- primary: method name
- secondary: method body
- message: duplicates body of "xxx"
-
Default Severity:Major
-
Impact:Low
-
Likelihood:High
-
Default Quality Profiles:Sonar way
-
Targeted languages:C#, C, C++, CSS, Flex, Java, JavaScript, Objective-C, PHP, Python, Swift, VB.Net, VB6
-
Remediation Function:Constant/Issue
-
Constant Cost:5min
Description
Having two methods in the same class with the same body is suspicious and potentially confusing. If it is due to a bad copy/paste, it should be fixed. If it's on purpose, it is clearer for the second method to simply call the first.
Noncompliant Code Example
public void doTheThing() { this.x = 4; } public void doTheOtherThing { // Noncompliant this.x = 4; }