Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 478 Bytes

GCop153.md

File metadata and controls

27 lines (20 loc) · 478 Bytes

GCop 153

"Instead use IEnumerable< T >.Lacks(T item)"

"Instead use IEnumerable< T >.Lacks(T item, bool caseSensitive)"

Rule description

Human brain can understand positive expressions and statements faster than negative ones. To improve code readability it is better to use Lacks rather than !Contains.

Example

if (!myStringList.Contains(myVar))
{
    ...
}

should be 🡻

if (myStringList.Lacks(myVar))
{
    ...
}