An assertion checks a literal, Assert.True(true) or the like, so it can never fail or always fails

tx0/csharp:constant-assertionrecommendedwarningmaintainability/testsdepth fastbug

What it finds

Assert.True(true) never fails and checks nothing; Assert.True(false) always fails without saying why, where Assert.Fail("reason") would. Both are usually placeholders or leftovers.

From the rule's source, constant_assertion.rs.

Example from the rule's tests
using Xunit; public class Placeholder{    [Fact]    public void Works()    {        Assert.True(true);tx0 reports: this assertion of a literal never fails        Assert.True(1 + 1 == 2);    }}
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 recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:constant-assertion" = "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:constant-assertion] reason="..."

tx0 explain tx0/csharp:constant-assertion shows the same in the terminal. Found a false positive? Report it.