-
What language is this for?
C# -
Which rule?
S3327 Loops should be simplified with “LINQ” expressions -
Why do you believe it’s a false-positive/false-negative?
Because it suggests to use Linq but Linq doesn’t work with spans
Using
-
SonarQube Cloud?
-
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
static bool Contains(ReadOnlySpan<char> source, ReadOnlySpan<char> value)
{
foreach(var segment in source.Split(' ')) // <== here
{
if (source[segment].Equals(value, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
Sonar wants us to write something like
foreach(var segment in source.Split(' ').Where...
which is not supported by Linq