The following code causes Sonar to raise a Bug warning that
'testData' is Nothing on at least one execution path.
It seems to be incorrect as it is impossible to reach the second line of code without testData being populated by the
Public Function TestDataContains(text as String) As String
Static testData As String = LoadTestData()
Thanks for your feedback.
LoadTestData() returns a string, it could theoretically return also
Nothing as string is a value type.
We can’t see content of the SonarCloud link.
The function returns
String, and the return type of
Boolean. Is that intentional?
Are there any attributes on the
LoadTestData() method? Can you share them with us?
That would be the same as a standard Dim testData = LoadTestData()
But that doesnt trigger a warning.
Issue created here: Fix S2259 FP: Support VB.NET static local variables · Issue #6271 · SonarSource/sonar-dotnet · GitHub
Please let us know the answers to my questions above, it might affect the result too.
That was a mistake as I tweaked the method to make it generic.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.