Fork me on GitHub
TypeName IfReturnTrueAnalyzer
Check Id CC0007
Category Usage
Severity Warning

Cause

Using an if/else to return true/false depending on the condition isn’t useful, as the condition is already a boolean it can be returned directly.

Example

bool something = true; if (something) { return true; } else { return false; }

Code fix

A code fix will be presented to you that will transform the code:

bool something = true; return something;

Code fix

Related rules

None

See also

TBD