avoid-commented-out-code
Warns when a section of code is commented out.
Keeping commented out code is usually unnecessary as the modern development environment includes a version control system (e.g. git) and it's preferable to keep incomplete code in a separate branch.
Overall, commented out code can be a sign of an incomplete or missing implementation which is usually a bug or hidden technical debt.
⚙️ Config
Set min-lines
(default is 1
) to configure the minimum number of lines after which a section of commented out code should be highlighted.
analysis_options.yaml
dart_code_metrics:
rules:
- avoid-commented-out-code:
min-lines: 1
Example
❌ Bad:
class Some {
// LINT: Avoid commented out code. Try using or removing it.
// void apply(String value) {
// print(value);
// }
void another() {
...
}
}
✅ Good:
class Some {
void another() {
...
}
// TODO: temporarily disabled, enable in 1.0
// void some () {
//
// }
}