Skip to content

continue_at_loop_end

Reports a continue that is the last statement of its loop’s body. Delete it.

Tier
advisory
Scope
Dart
Lowest preset
recommended
Fix
deletes the statement

A continue that is the last of several statements of the body of the loop it continues (for, for-in, while, do), without a label or with the label of that loop.

It does not report:

  • a continue that ends a block of an if or a case of a switch inside the body;
  • a continue with the label of an outer loop;
  • a continue that is the only statement of the body.

No fix is offered where a comment stands before the statement, or after it on its line.

Nothing is left in the body to skip, so the next pass starts the same without it.

Violating
for (final value in values) {
show(value);
continue;
}
Corrected
for (final value in values) {
show(value);
}

Set under the assay: key of the project’s root analysis_options.yaml.

Rule parameter Default Effect
enabled true false switches the rule off for the whole project.
exclude [] Path globs where the rule is silent.

Write why on the line directly above the suppression:

// The statement marks where the next release adds a step.
// ignore: assay/continue_at_loop_end

// ignore_for_file: assay/continue_at_loop_end silences it in a whole file, and // ignore: continue_at_loop_end without the prefix works too. See Suppressions.