Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.07 KB

no-useless-jump-label.md

File metadata and controls

54 lines (39 loc) · 1.07 KB

no-useless-jump-label

🔧 fixable

Disallows continue label; and break label; where the label is not necessary.

Rationale

Jump labels are typically used to jump to or out of a control flow statement other than the enclosing one. It may cause confusion ff the target of the jump is the same with and without the label. Often times this is a leftover from refactoring.

Examples

👎 Examples of incorrect code

foo: bar: while (true) {
  if (condition)
    continue foo;
  break bar;
}

👍 Examples of correct code

while (true) {
  if (condition)
    continue;
  break;
}

outer: while (true) {
  switch (v) {
    case true:
      break outer;
  }
}

blockLabel: {
  if (condition)
    break blockLabel;
}

Further Reading

Related Rules