Skip to content

Commit de2f8c7

Browse files
SONARJAVA-2595 Fix Quality
1 parent 640f1a3 commit de2f8c7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

java-checks/src/test/files/checks/CompareToNotOverloadedCheck.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public int compareTo(B b) { // Noncompliant {{Refactor this method so that its
1414
public int compareTo(A a) { // Compliant
1515
return 0;
1616
}
17+
18+
public int compareTo(A a, B b) { // Compliant
19+
return 0;
20+
}
1721
}
1822

1923
class C implements Comparable{
@@ -41,9 +45,16 @@ public int compareTo(FooBar rhs) { // Noncompliant: Parameter should be of type
4145
}
4246

4347
class D {
44-
int compareTo(A a) { // Compliant
48+
public int compareTo(A a) { // Compliant
49+
return 1;
50+
}
51+
52+
}
53+
54+
class F extends B{
55+
public int compareTo1(B b) { // Compliant
4556
return 1;
4657
}
4758
}
4859

49-
}
60+
}

java-checks/src/test/java/org/sonar/java/checks/CompareToNotOverloadedCheckTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ public class CompareToNotOverloadedCheckTest {
2626
@Test
2727
public void test() {
2828
JavaCheckVerifier.verify("src/test/files/checks/CompareToNotOverloadedCheck.java", new CompareToNotOverloadedCheck());
29+
JavaCheckVerifier.verifyNoIssueWithoutSemantic("src/test/files/checks/CompareToNotOverloadedCheck.java", new CompareToNotOverloadedCheck());
30+
2931
}
3032
}

0 commit comments

Comments
 (0)