== Why is this an issue?

Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.


This rule raises an issue when a ``++private++`` method or constructor of a class/struct takes a parameter without using it.

=== Noncompliant code example

[source,csharp]
----
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

[source,csharp]
----
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:


* The ``++this++`` parameter of extension methods.
* Methods decorated with attributes.
* Empty methods.
* Methods which only throw ``++NotImplementedException++``.
* Main methods.
* ``++virtual++``, ``++override++`` methods.
* interface implementations.


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

* Remove this unused method parameter "{0}".
* Remove this parameter "{0}", whose value is ignored in the method.


'''
== Comments And Links
(visible only on this page)

=== on 6 Mar 2017, 17:55:59 Amaury Levé wrote:
\[~freddy.mallet] Shall we ignore all empty methods or only public ones? If you say all of them, shall we also ignore empty Ctor?

About ``++static void Main(string[] args)++`` do you mean we also ignore the argument even if the method is not empty?

=== on 7 Mar 2017, 10:08:34 Jean-Christophe Collet wrote:
My suggestions:

* Ignore all empty methods including constructors (they should be flagged by another issue anyway)
* Yes, since Main(string[] args) is a 'non-negotiable' signature, we should ignore the case where 'args' is not used.


=== on 7 Jan 2019, 16:44:49 Nicolas Harraudeau wrote:
The new description matches the existing implementation. It just explains more precisely what cases raise an issue.

include::../comments-and-links.adoc[]

endif::env-github,rspecator-view[]
