Telerik UI for UWP


An unconditional break

V3020 An unconditional ‘break’ within a loop. NodePool.cs 189

public IEnumerable<KeyValuePair<int, List<T>>>
                GetUnfrozenDisplayedElements()
{
  foreach (var item in this.generatedContainers)
  {
    foreach (var pair in item.Value)
    {
      if (!pair.IsFrozen)
      {
        yield return item;
      }
      break;
    }
  }
}

The break statement is not part of the if statement. It will execute no matter what value is stored in pair.IsFrozen, so the foreach loop will iterate only once.

Please click here to see more bugs from this project.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.