Open
Description
In looking through various code bases, I've seen the following pattern repeatedly:
if (Regex.IsMatch(pattern))
{
Match m = Regex.Match(pattern);
...
}
That just doubles the work involved when there is a match. It should instead be:
if (Regex.Match(pattern) is { Success: true } m)
{
...
}
or something similar. We should have an analyzer that flags these duplicative guards and a fixer that transforms into something like the latter.
Activity