Description of the false positive
Note from code scanning:
Missed opportunity to use Select
This foreach loop immediately maps its iteration variable to another variable
- consider mapping the sequence explicitly using '.Select(...)'.
However, the LINQ Select method cannot be used when the value is received via an async method, such as this code from a Playwright test:
Code samples or links to source code
var hasContactOption = false;
foreach (var locator in contactSelectors.Select(s => Page.Locator(s)))
{
var elements = await locator.CountAsync();
if (elements > 0)
{
hasContactOption = true;
break;
}
}
URL to the alert on GitHub code scanning (optional)
https://github.com/CNinnovation/cninnovationweb/security/code-scanning/284
Description of the false positive
Note from code scanning:
However, the LINQ
Selectmethod cannot be used when the value is received via an async method, such as this code from a Playwright test:Code samples or links to source code
URL to the alert on GitHub code scanning (optional)
https://github.com/CNinnovation/cninnovationweb/security/code-scanning/284