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
What it reports
Section titled “What it reports”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
continuethat ends a block of anifor a case of aswitchinside the body; - a
continuewith the label of an outer loop; - a
continuethat 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.
Example
Section titled “Example”Violating
for (final value in values) { show(value); continue;}Corrected
for (final value in values) { show(value);}Rule parameters
Section titled “Rule parameters”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. |
Suppressing it
Section titled “Suppressing it”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.