mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
Merge pull request #16004 from tamasvajk/feature/adjust-incorrect-compare-to
C#: Simplify the output of `cs/wrong-compareto-signature` to remove e…
This commit is contained in:
@@ -33,13 +33,13 @@ predicate compareToMethod(Method m, Type paramType) {
|
|||||||
paramType = m.getAParameter().getType()
|
paramType = m.getAParameter().getType()
|
||||||
}
|
}
|
||||||
|
|
||||||
from Method m, RefType declaringType, Type actualParamType
|
from Method m, RefType declaringType, Type actualParamType, string paramTypeName
|
||||||
where
|
where
|
||||||
m.isSourceDeclaration() and
|
m.isSourceDeclaration() and
|
||||||
declaringType = m.getDeclaringType() and
|
declaringType = m.getDeclaringType() and
|
||||||
compareToMethod(m, actualParamType) and
|
compareToMethod(m, actualParamType) and
|
||||||
not implementsIComparable(declaringType, actualParamType)
|
not implementsIComparable(declaringType, actualParamType) and
|
||||||
|
paramTypeName = actualParamType.getName()
|
||||||
select m,
|
select m,
|
||||||
"The parameter of this 'CompareTo' method is of type $@, but $@ does not implement 'IComparable<$@>'.",
|
"The parameter of this 'CompareTo' method is of type '" + paramTypeName +
|
||||||
actualParamType, actualParamType.getName(), declaringType, declaringType.getName(),
|
"', but the declaring type does not implement 'IComparable<" + paramTypeName + ">'."
|
||||||
actualParamType, actualParamType.getName()
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
category: minorAnalysis
|
||||||
|
---
|
||||||
|
* The alert message of `cs/wrong-compareto-signature` has been changed to remove unnecessary element references.
|
||||||
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
| IncorrectCompareToSignature.cs:5:16:5:24 | CompareTo | The parameter of this 'CompareTo' method is of type $@, but $@ does not implement 'IComparable<$@>'. | IncorrectCompareToSignature.cs:3:10:3:10 | T | T | IncorrectCompareToSignature.cs:3:7:3:11 | C1`1 | C1`1 | IncorrectCompareToSignature.cs:3:10:3:10 | T | T |
|
| IncorrectCompareToSignature.cs:5:16:5:24 | CompareTo | The parameter of this 'CompareTo' method is of type 'T', but the declaring type does not implement 'IComparable<T>'. |
|
||||||
| IncorrectCompareToSignatureBad.cs:5:16:5:24 | CompareTo | The parameter of this 'CompareTo' method is of type $@, but $@ does not implement 'IComparable<$@>'. | IncorrectCompareToSignatureBad.cs:3:7:3:9 | Bad | Bad | IncorrectCompareToSignatureBad.cs:3:7:3:9 | Bad | Bad | IncorrectCompareToSignatureBad.cs:3:7:3:9 | Bad | Bad |
|
| IncorrectCompareToSignatureBad.cs:5:16:5:24 | CompareTo | The parameter of this 'CompareTo' method is of type 'Bad', but the declaring type does not implement 'IComparable<Bad>'. |
|
||||||
|
|||||||
Reference in New Issue
Block a user