rspec/rules/S3878/vbnet/rule.adoc

36 lines
815 B
Plaintext
Raw Normal View History

== Why is this an issue?
There's no point in creating an array solely for the purpose of passing it to a `ParamArray` parameter. Simply pass the elements directly. They will be consolidated into an array automatically.
=== Noncompliant code example
[source,vbnet]
----
Class SurroundingClass
Public Sub Base()
Method(New String() { "s1", "s2" }) ' Noncompliant: unnecessary
Method(New String(12) {}) ' Compliant
End Sub
Public Sub Method(ParamArray args As String())
' Do something
End Sub
End Class
----
=== Compliant solution
[source,vbnet]
----
Class SurroundingClass
Public Sub Base()
Method("s1", "s2")
Method(New String(12) {})
End Sub
Public Sub Method(ParamArray args As String())
' Do something
End Sub
End Class
----