The result of new is compared with null, which never holds since new throws on failure

tx0/cpp:null-check-after-newrecommendedwarningmaintainability/designdepth fastsmell

What it finds

Plain new reports a failed allocation with std::bad_alloc and never returns null, so the check after it is dead code that suggests a handling that does not happen. new (std::nothrow) returns null instead, if that is what the code expects.

From the rule's source, null_check_after_new.rs.

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/cpp:null-check-after-new" = "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/cpp:null-check-after-new] reason="..."

tx0 explain tx0/cpp:null-check-after-new shows the same in the terminal. Found a false positive? Report it.