Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a linter ignore comment to suppress a warning regarding unnecessary type assertions when processing class names for autocompletion. The reviewer recommends avoiding the use of ignore comments by refactoring the code to use .whereType<String>(), which is a more idiomatic way to handle the collection and avoids the linter issue entirely.
| final classNames = classes.map((clazz) => clazz.name); | ||
| // ignore: avoid-unnecessary-type-assertions | ||
| result.addAll(classNames.nonNulls); |
There was a problem hiding this comment.
[CONCERN] Avoid using // ignore comments to silence linter warnings. If DCM is incorrectly flagging nonNulls as an unnecessary type assertion, using whereType<String>() is a standard alternative that often avoids such false positives while remaining clear and null-safe. Inlining the operation also improves readability by removing a single-use local variable.
| final classNames = classes.map((clazz) => clazz.name); | |
| // ignore: avoid-unnecessary-type-assertions | |
| result.addAll(classNames.nonNulls); | |
| result.addAll(classes.map((clazz) => clazz.name).whereType<String>()); |
References
- Maintainability: Code should be easy to modify and extend. Consistency: Adhering to consistent style across all DevTools packages improves collaboration. (link)
| if (classes != null) { | ||
| // Autocomplete class names as well | ||
| final classNames = classes.map((clazz) => clazz.name); | ||
| // ignore: avoid-unnecessary-type-assertions |
There was a problem hiding this comment.
nit: add a reason after the ignore
There was a problem hiding this comment.
or actually, is the lint firing because .nonNulls can be removed?
There was a problem hiding this comment.
.nonNulls cannot be removed. I think it is a bug in DCM.
But this DCM CI run says that the ignore is unnecessary.
But I see on other CI that I just kicked off, we still have DCM issues: https://github.com/flutter/devtools/actions/runs/24530067465/job/72178946851?pr=9755
There was a problem hiding this comment.
do you have the same version of DCM installed that we use on the CI? 1.36.0
There was a problem hiding this comment.
I do not have DCM installed.
No description provided.