A Count or Length is tested for being negative, which it never is
What it finds
items.Count < 0 is always false and text.Length >= 0 always true: sizes are never negative. The intent was usually == 0 or > 0.
From the rule's source, negative_size_check.rs.
using System.Collections.Generic;using System.Linq; class Sizes{ bool Check(List<int> items, string text) { if (items.Count < 0)tx0 reports: items.Count < 0 is always false: sizes are never negative { return false; } return text.Length >= 0 && items.Count() > 0;tx0 reports: text.Length >= 0 is always true: sizes are never negative }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/csharp:negative-size-check" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:negative-size-check] reason="..."tx0 explain tx0/csharp:negative-size-check shows the same in the terminal. Found a false positive? Report it.