An equality assertion compares with null, true or false, where a dedicated assertion reads better

tx0/csharp:equality-assert-of-null-or-boolallwarningmaintainability/testsdepth faststyle

What it finds

Assert.Equal(null, x) and Assert.AreEqual(true, x) work, but Assert.Null(x) and Assert.True(x) say what is checked and give clearer messages.

From the rule's source, equality_assert_of_null_or_bool.rs.

Example from the rule's tests
using Xunit; public class Lookup{    [Fact]    public void Finds()    {        object found = null;        Assert.Equal(null, found);tx0 reports: an equality assertion compares with null        Assert.Null(found);    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:equality-assert-of-null-or-bool" = "warning"

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:equality-assert-of-null-or-bool] reason="..."

tx0 explain tx0/csharp:equality-assert-of-null-or-bool shows the same in the terminal. Found a false positive? Report it.