mirror of
https://github.com/github/codeql.git
synced 2026-01-11 13:40:21 +01:00
21 lines
609 B
Plaintext
21 lines
609 B
Plaintext
/**
|
|
* @name Useless call to GetHashCode()
|
|
* @description Calling 'GetHashCode()' on integer types is redundant because the method always returns
|
|
* the original value.
|
|
* @kind problem
|
|
* @problem.severity recommendation
|
|
* @precision high
|
|
* @id cs/useless-gethashcode-call
|
|
* @tags readability
|
|
* useless-code
|
|
*/
|
|
|
|
import csharp
|
|
import semmle.code.csharp.frameworks.System
|
|
|
|
from MethodCall mc, IntegralType t
|
|
where
|
|
mc.getTarget() instanceof GetHashCodeMethod and
|
|
t = mc.getQualifier().getType()
|
|
select mc, "Calling GetHashCode() on type " + t.toStringWithTypes() + " is redundant."
|