rspec/rules/S1172/csharp/rule.adoc

57 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
This rule raises an issue when a ``++private++`` method of a class/struct takes a parameter without using it.
2020-06-30 12:47:33 +02:00
== Noncompliant Code Example
----
private void DoSomething(int a, int b) // "b" is unused
{
Compute(a);
}
private void DoSomething2(int a) // value of "a" is unused
{
a = 10;
Compute(a);
}
----
== Compliant Solution
----
private void DoSomething(int a)
{
Compute(a);
}
private void DoSomething2()
{
var a = 10;
Compute(a);
}
----
== Exceptions
This rule doesn't raise any issue in the following contexts:
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
* The ``++this++`` parameter of extension methods.
2020-06-30 12:47:33 +02:00
* Methods decorated with attributes.
* Empty methods.
2021-01-27 13:42:22 +01:00
* Methods which only throw ``++NotImplementedException++``.
2020-06-30 12:47:33 +02:00
* Main methods.
2021-01-27 13:42:22 +01:00
* ``++virtual++``, ``++override++`` methods.
2020-06-30 12:47:33 +02:00
* interface implementations.
include::../see.adoc[]
ifdef::rspecator-view[]
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::rspecator-view[]