rspec/rules/S1172/vbnet/rule.adoc

64 lines
1.4 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
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++`` procedure of a ``++Class++``, ``++Module++`` or ``++Structure++`` takes a parameter without using it.
2020-06-30 12:47:33 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2020-06-30 12:47:33 +02:00
----
Private Sub DoSomething(ByVal a As Integer, ByVal b as Integer) ' "b" is unused
Compute(a)
End Sub
Private Function DoSomething2(ByVal a As Integer, ByVal b As Integer) As Integer ' "a" is unused
Compute(b)
Return b
End Function
----
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2020-06-30 12:47:33 +02:00
----
Private Sub DoSomething(ByVal a As Integer)
Compute(a)
End Sub
Private Function DoSomething2(ByVal b As Integer) As Integer
Compute(b)
Return b
End Function
----
=== Exceptions
2020-06-30 12:47:33 +02:00
This rule doesn't raise any issue in the following contexts:
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
* Procedures decorated with attributes.
* Empty procedures.
2021-01-27 13:42:22 +01:00
* Procedures which only throw ``++NotImplementedException++``.
2020-06-30 12:47:33 +02:00
* Main methods.
2021-01-27 13:42:22 +01:00
* ``++virtual++``, ``++override++`` procedures.
2020-06-30 12:47:33 +02:00
* Interface implementations.
* Event handlers.
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[]