PVS Studio throws V3022: Expression 'list.Count > 1' is always false. Program.cs 20
public class Program
{
private static void Main()
{
var list = new List<string>();
var keyvaluelist = new List<(string, string)>() { ("1", "2"), ("3", "4") };
list.Add(DateTime.Now.ToString());
foreach ((string Key, string Value) in keyvaluelist)
list.Add(DateTime.Now.ToString());
if (list.Count > 1)
Console.WriteLine(list.Count);
}
}
Is this a false positive?
This indeed looks like a false positive. We'll investigate it further and fix it in one of the future releases.
Also, as was mentioned in the comments before, false-positive reports are not the right format of questions for stackoverflow, so you can send them directly to PVS-Studio support at [email protected] or https://www.viva64.com/en/about-feedback/.
Thanks for your feedback!