All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.vbnet.S3878.html Maven / Gradle / Ivy

There is a newer version: 10.5.0.109200
Show newest version

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy