I'm testing SonarQube in order to check the quality of my code.
In a loop, I have something like that :
foreach(var someVar in someList)
{
if(condition)
//Do stuff
else
break;
}
SonarQube tells me :
Refactor the code in order to remove this break statement.
I can do it by constructing a list which respects my condition, but can someone explain why using break
is considered as a bad practice ?