
## Review A dedicated reviewer checked the rule description successfully for: - [x] logical errors and incorrect information - [x] information gaps and missing content - [x] text style and tone - [x] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
55 lines
892 B
Plaintext
55 lines
892 B
Plaintext
include::../rationale.adoc[]
|
|
|
|
=== Exceptions
|
|
|
|
Unused locally created resources in a `using` statement are not reported.
|
|
|
|
[source,csharp]
|
|
----
|
|
using(var t = new TestTimer()) // t never used, but compliant.
|
|
{
|
|
//...
|
|
}
|
|
----
|
|
|
|
include::../how-to-fix-it.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
public int NumberOfMinutes(int hours)
|
|
{
|
|
int seconds = 0; // Noncompliant - seconds is unused
|
|
return hours * 60;
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
public int NumberOfMinutes(int hours)
|
|
{
|
|
return hours * 60;
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|