Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Future<Set<String>> _libraryMemberAutocompletes(
if (classes != null) {
// Autocomplete class names as well
final classNames = classes.map((clazz) => clazz.name);
// ignore: avoid-unnecessary-type-assertions
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a reason after the ignore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or actually, is the lint firing because .nonNulls can be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have the same version of DCM installed that we use on the CI? 1.36.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@incendial for the possible DCM bug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have DCM installed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@incendial for the possible DCM bug

Thanks, looking into it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the issue was resolved without adding the ignore #9755? I also don't see the warning locally.

result.addAll(classNames.nonNulls);
Comment on lines 203 to 205
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[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.

Suggested change
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
  1. Maintainability: Code should be easy to modify and extend. Consistency: Adhering to consistent style across all DevTools packages improves collaboration. (link)

}

Expand Down
Loading