Files
codeql/csharp/ql/src/Language Abuse/UnusedPropertyValue.ql
2019-01-02 12:59:07 +01:00

25 lines
771 B
Plaintext

/**
* @name Property value is not used when setting a property
* @description Ignoring the value assigned to a property is potentially confusing and
* can lead to unexpected results.
* @kind problem
* @problem.severity warning
* @precision high
* @id cs/unused-property-value
* @tags reliability
* maintainability
* language-features
*/
import csharp
from Setter setter
where
not exists(setter.getAParameter().getAnAccess()) and
not exists(ThrowStmt t | t.getEnclosingCallable() = setter) and
setter.hasBody() and // Trivial setter is OK
not setter.getDeclaration().overrides() and
not setter.getDeclaration().implements() and
not setter.getDeclaration().isVirtual()
select setter, "Value ignored when setting property."