prefer-commenting-analyzer-ignores
Warns when // ignore:
comments are left without any additional description of why this ignore is applied.
info
By default, this rule doesn't trigger on global ignore_for_file:
comments.
⚙️ Config
Set ignore-global
(default is true
) to check global ignore comments (example).
analysis_options.yaml
dart_code_metrics:
rules:
- prefer-commenting-analyzer-ignores:
ignore-global: true
Example
❌ Bad:
// LINT: Prefer adding a description to the analyzer ignores. Providing a clear description may help future readers better understand the reason for the ignore.
// ignore: deprecated_member_use
final map = Map();
// LINT: Prefer adding a description to the analyzer ignores. Providing a clear description may help future readers better understand the reason for the ignore.
// ignore: deprecated_member_use, long-method
final set = Set();
✅ Good:
// Ignored for some reasons
// ignore: deprecated_member_use
final list = List();
// ignore: deprecated_member_use same line ignore
final queue = Queue();
// ignore: deprecated_member_use, long-method multiple same line ignore
final linkedList = LinkedList();
Example with "ignore-global"
Config
analysis_options.yaml
dart_code_metrics:
rules:
- prefer-commenting-analyzer-ignores:
ignore-global: false
❌ Bad:
// LINT: Prefer adding a description to the analyzer ignores. Providing a clear description may help future readers better understand the reason for the ignore.
// ignore_for_file: deprecated_member_use