Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 721 Bytes

File metadata and controls

49 lines (34 loc) · 721 Bytes
layout page
title CC0007
tagline IfReturnTrueAnalyzer

|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

{% highlight csharp %} bool something = true;

if (something) { return true; } else { return false; } {% endhighlight %}

Code fix

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

{% highlight csharp %} bool something = true;

return something; {% endhighlight %}

![Code fix]({{ BASE_PATH }}/assets/images/CC0007/codefix0.png)

Related rules

None

See also

TBD