mirror of
https://github.com/github/codeql.git
synced 2026-06-28 16:17:03 +02:00
24 lines
665 B
Plaintext
24 lines
665 B
Plaintext
/**
|
|
* @name Redundant ToString() call
|
|
* @description Explicit calls to `ToString()` can be removed when the call
|
|
* appears in a context where an implicit conversion exists.
|
|
* @kind problem
|
|
* @problem.severity recommendation
|
|
* @precision high
|
|
* @id cs/useless-tostring-call
|
|
* @tags quality
|
|
* maintainability
|
|
* useless-code
|
|
*/
|
|
|
|
import csharp
|
|
import semmle.code.csharp.commons.Strings
|
|
import semmle.code.csharp.frameworks.System
|
|
|
|
from MethodCall mc
|
|
where
|
|
mc instanceof ImplicitToStringExpr and
|
|
mc.getTarget() instanceof ToStringMethod and
|
|
not mc.getQualifier() instanceof BaseAccess
|
|
select mc, "Redundant call to 'ToString'."
|