avoid-unnecessary-continue
- Group
- Style
- Path
lint/style/avoid-unnecessary-continue- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 160 of 512
Flags an unlabeled continue at the end of a loop body or its final branch.
Ancestor inspection stops at try/finally, switch and function boundaries.
Invalid
void classic() {
for (var i = 0; i < 3; i++) {
print(i);
continue;
}
}
void iterable(List<int> values) {
for (final value in values) {
print(value);
continue;
}
}
void waiting(bool ready) {
while (ready) {
continue;
}
}
void once() {
do {
continue;
} while (false);
}
Future<void> asynchronous(Stream<int> values) async {
await for (final value in values) {
print(value);
continue;
}
}
void unbraced(bool ready) {
while (ready) continue;
}
void conditionalTail(List<int> values) {
for (final value in values) {
if (value < 0) {
continue;
} else {
print(value);
continue;
}
}
} print(i); continue; print(value); continue; while (ready) { continue; do { continue; print(value); continue;void unbraced(bool ready) { while (ready) continue; if (value < 0) { continue; print(value); continue;Valid
void guarded(List<int> values) {
for (final value in values) {
if (value < 0) continue;
print(value);
}
}
void labeled(List<int> values) {
outer: for (final first in values) {
for (final second in values) {
print(first + second);
continue outer;
}
}
}
void conditionalWork(List<int> values) {
for (final value in values) {
if (value < 0) { continue; }
print(value);
}
}
void finallyTail(bool ready) {
while (ready) {
try { continue; } finally { break; }
}
}
void laterWork(bool ready) {
while (ready) {
{ continue; }
print('later');
}
}
void noContinue() {
for (var i = 0; i < 3; i++) { print(i); }
do { print('once'); } while (false);
}Configure avoid-unnecessary-continue
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"avoid-unnecessary-continue": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/avoid-unnecessary-continue: <reason>More style rules
- avoid-unnecessary-getter
Flags a getter that only exposes a private final field.
- avoid-unnecessary-if
Flags an if branch that only returns the same expression as the following return.
- avoid-unnecessary-length-check
Empty collections already skip
for-inandforEachbodies. - avoid-unnecessary-local-variable
Reports a single-use local used only to initialize the next local.
- avoid-unnecessary-negations
Simplifies negated bool literals and equality comparisons with a logical negation on both sides.
- avoid-unnecessary-overrides-in-stateflutter
Redundant Flutter State overrides that drop inherited
@protected. - avoid-unnecessary-reassignment
Reports an eager local initializer immediately overwritten without a read.
- avoid-unnecessary-return
Flags bare returns at the end of a function or its final if/block branches.