Repository navigation
dcm check-unused-code false positives #9907
Description
Activity
@kenzieschmoll trying to reproduce these and I'm getting
✔ no unused code found!. What DCM version do you have? I'm running with the latest 1.38.3.Also, adding
// ignore: unused-codefor code that is no longer used only in asserts is not needed (e.g,_AlternateCheckedModeBanneror_debugInitVmServiceCache).
By default, the tool skips usages in asserts so that assert-only usages at least have a comment with the context of why that code is assert-only. Maybe we should have that in our docs.Ah, I see, there are excludes that need to be removed first, now I can reproduce it.
Fixed for both
_initializedfields and_renderObjectInitialized, will be in the next release.I am now on 1.38.3.
Another false positive (line numbers may be off because I am on my local branch with changes):
packages/devtools_app/lib/src/shared/primitives/utils.dart (2 issues): ✖ this getter is used but never assigned a value at packages/devtools_app/lib/src/shared/primitives/utils.dart:450:3 ✖ this getter is used but never assigned a value at packages/devtools_app/lib/src/shared/primitives/utils.dart:452:3Associated code:
extension SafeAccess<T> on Iterable<T> { T? get safeFirst => isNotEmpty ? first : null; T? get safeLast => isNotEmpty ? last : null; }
Reacted by Dmitry ZhifarskyThanks. I'm very surprised to see a getter falling into the "not assigned" category 😅🙈
But I was able to reproduce it, investigatingEdit: fixed, will be in the next release
Another false positive:
packages/devtools_shared/lib/src/utils/file_utils.dart (1 issue): ✖ unused top level variable _fileUriPrefix at packages/devtools_shared/lib/src/utils/file_utils.dart:8:1Reacted by Dmitry Zhifarsky- addedP2important to work on, but not at the top of the work list.important to work on, but not at the top of the work list.cost: lowLow engineering cost to implement.Low engineering cost to implement.
on Aug 3, 2026
Command:
dcm check-unused-code packages/devtools_app/ --exclude-public-apiFalse positives (one common theme I see here is that anything used in
assertstatements is falsely determined "unused"):I will add more false positives to this list as I find them (working through different directories #9906).
@incendial