avoid-commented-out-code
- Group
- Suspicious
- Path
lint/suspicious/avoid-commented-out-code- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 33 of 512
Flags ordinary comments that contain recognizable Dart statements.
Delete obsolete code rather than keeping it in comments. This deliberately conservative heuristic recognizes declarations, calls, assignments, and return/throw statements with code punctuation. Documentation comments, fenced examples, prose, and TODO/FIXME notes are not reported.
Invalid
void example() {
// print('old');
// final count = 3;
// value = false;
// return null;
/* throw StateError('obsolete'); */
// service.refresh();
// final int count = 1;
// return 42;
}
// void obsolete(String value) {
// }
// class Obsolete {
// }
/*
* print('old block');
*/void example() { // print('old'); // print('old'); // final count = 3; // final count = 3; // value = false; // value = false; // return null; // return null; /* throw StateError('obsolete'); */ /* throw StateError('obsolete'); */ // service.refresh(); // service.refresh(); // final int count = 1; // final int count = 1; // return 42;} // void obsolete(String value) {// } // class Obsolete {// } /*Valid
/// Example implementation:
/// print('documented');
/** final count = 3; */
void example() {
// Explain why this call is required.
// Use service.refresh(); after reconnecting.
// TODO: print('enable when ready');
// FIXME: value = false;
// The value = false; means it is disabled.
// Max retries = 3;
// The value = false;
// ```dart
// print('example');
// ```
// Values include `true` and `false`.
print('live');
}Configure avoid-commented-out-code
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"suspicious": {
"avoid-commented-out-code": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/suspicious/avoid-commented-out-code: <reason>More suspicious rules
- avoid-double-slash-imports
Reject repeated path separators in directive URIs (import, export and part).
- avoid-dynamic
avoid-dynamicFlags explicit
dynamictype annotations. - avoid-empty-else
avoid_empty_elserecommendedFlags an
elseclause whose body is an empty statement (else ;). - avoid-ignoring-return-values
avoid-ignoring-return-valuesFlags a discarded call whose resolved return type is non-void.
- avoid-incorrect-uri
Reject runtime-invalid Uri constructor arguments: conflicting path or query inputs and query parameter values that are neither null, strings nor iterables of strings.
- avoid-inverted-boolean-checks
Prefer direct equality comparisons and De Morgan forms in control-flow conditions.
- avoid-multi-assignment
Split chained assignments into separate statements.
- avoid-mutating-parameters
Detects writes through named function, method and constructor parameter objects.