1
Vote

JSL1003 - Sometimes not as performance friendly

description

The rule JSL1003 can be a bit misleading in the case of a loop.
 
bool isTrue = string.IsNullOrWhitespace(x);
 
while (true)
{
if (isTrue)
{
// do something
}
else
{
// do something else
}
}
 
In my opinion it doesn't makes sense to set the 'isTrue' variable on each loop iteration.
Could you implement a check that the rule will be ignored if a loop is around the usage of the variable?

comments