Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-329575: Suggested refactoring: Swap if/else conditions

$
0
0
Reporter Ian Jirka (ianjirka) Ian Jirka (ianjirka)
Created Aug 29, 2012 11:05:49 PM
Updated Apr 20, 2018 6:21:07 PM
Resolved Apr 20, 2018 6:21:07 PM
Subsystem Refactorings
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Obsolete
Type Feature
Fix version Backlog
Affected versions 7.0.1
Fixed In Version ReSharper Undefined
VsVersion All Versions
Sometimes swapping if/else conditions can improve readability:

if( !foo )
{
A();
}
else
{
B();
}

–>

if(foo)
{
B();
}
else
{
A();
}

This is something straightforward for a machine to perform, and is more useful with more complicated expressions and/or larger code blocks. (You do have to make sure you preserve any side-effects in the test expression though)

Viewing all articles
Browse latest Browse all 106942

Trending Articles