rspec/rules/S2234/vbnet/rule.adoc

55 lines
1.3 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:48:07 +02:00
When the names of parameters in a procedure call match the names of the procedure arguments, it contributes to a clearer, more readable code. However, when the names match but are passed in a different order than the method arguments, it indicates a mistake in the parameter order which will likely lead to unexpected results.
=== Noncompliant code example
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2020-06-30 12:48:07 +02:00
----
Public Function Divide(ByVal divisor As Integer, ByVal dividend As Integer) As Double
Return divisor / dividend
End Function
Public Sub DoTheThing()
Dim divisor = 15
Dim dividend = 5
Dim result = Divide(dividend, divisor) ' Noncompliant; operation succeeds, but result is unexpected
'...
End Sub
----
=== Compliant solution
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,vbnet]
2020-06-30 12:48:07 +02:00
----
Public Function Divide(ByVal divisor As Integer, ByVal dividend As Integer) As Double
Return divisor / dividend
End Function
Public Sub DoTheThing()
Dim divisor = 15
Dim dividend = 5
Dim result = Divide(divisor, dividend)
'...
End Sub
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]