if (customer.Orders.Where(o => o.IsOverdue).Count() > 0)
{
SendReminder(customer);
}Deterministic line match: flags the method call `.Count()` with no arguments compared to 0 or 1 with any comparison operator, on either side.
`.Count() > 0` or `.Count() == 0` used to ask whether a sequence has any elements. On a lazy enumerable it walks every element to answer a yes/no question.
Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.
if (customer.Orders.Where(o => o.IsOverdue).Count() > 0)
{
SendReminder(customer);
}Deterministic line match: flags the method call `.Count()` with no arguments compared to 0 or 1 with any comparison operator, on either side.
if (customer.Orders.Any(o => o.IsOverdue))
{
SendReminder(customer);
}Use `.Any()` for the non-empty check and `!.Any()` for the empty one. On a materialized collection, the `Count` or `Length` property is also fine.
Agents reach for the counting call by habit because it reads naturally, without considering what it costs on a query.
ai-slop/csharp-linq-count
ai-slop
Deterministic line match: flags the method call `.Count()` with no arguments compared to 0 or 1 with any comparison operator, on either side.
The `.Count` property of collections, `.Count(predicate)` calls, and comparisons against other numbers are not flagged.
Part of aislop's C# rule set. First-class C# support, including C#-specific AI-slop rules, arrived in aislop v0.14.1.