Visitar URL original
`dcm check-unused-code` false positives · Issue #9907 · flutter/devtools · GitHub
Skip to content

dcm check-unused-code false positives #9907

Description

@kenzieschmoll

Command: dcm check-unused-code packages/devtools_app/ --exclude-public-api

False positives (one common theme I see here is that anything used in assert statements is falsely determined "unused"):

packages/devtools_app/test/test_infra/utils/extent_delegate_utils.dart (1 issue):
    ✖ unused field _renderObjectInitialized
      at packages/devtools_app/test/test_infra/utils/extent_delegate_utils.dart:19:3

packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart (1 issue):
    ✖ unused field _initialized
      at packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart:81:3

packages/devtools_app/lib/src/framework/home_screen.dart (2 issues):
    ✖ unused method _debugInitVmServiceCache
      at packages/devtools_app/lib/src/framework/home_screen.dart:174:3

packages/devtools_app/lib/src/app.dart (2 issues):
    ✖ unused class _AlternateCheckedModeBanner
      at packages/devtools_app/lib/src/app.dart:616:1
    ✖ unused constructor _AlternateCheckedModeBanner
      at packages/devtools_app/lib/src/app.dart:622:3

packages/devtools_app/lib/src/screens/performance/panes/timeline_events/perfetto/_perfetto_controller_web.dart (1 issue):
    ✖ unused field _initialized
      at packages/devtools_app/lib/src/screens/performance/panes/timeline_events/perfetto/_perfetto_controller_web.dart:162:3

I will add more false positives to this list as I find them (working through different directories #9906).

@incendial

Activity

  1. incendial commented on Jul 22, 2026

    @incendial
    Contributor

    @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-code for code that is no longer used only in asserts is not needed (e.g, _AlternateCheckedModeBanner or _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.

  2. incendial commented on Jul 22, 2026

    @incendial
    Contributor

    Ah, I see, there are excludes that need to be removed first, now I can reproduce it.

  3. incendial commented on Jul 22, 2026

    @incendial
    Contributor

    Fixed for both _initialized fields and _renderObjectInitialized, will be in the next release.

  4. kenzieschmoll commented on Jul 27, 2026

    @kenzieschmoll
    MemberAuthor

    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:3
    

    Associated code:

    extension SafeAccess<T> on Iterable<T> {
      T? get safeFirst => isNotEmpty ? first : null;
    
      T? get safeLast => isNotEmpty ? last : null;
    }
  5. incendial commented on Jul 27, 2026

    @incendial
    Contributor

    Thanks. I'm very surprised to see a getter falling into the "not assigned" category 😅🙈
    But I was able to reproduce it, investigating

    Edit: fixed, will be in the next release

  6. kenzieschmoll commented on Jul 30, 2026

    @kenzieschmoll
    MemberAuthor

    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:1
    
  7. added
    P2important to work on, but not at the top of the work list.
    cost: lowLow engineering cost to implement.
    on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2important to work on, but not at the top of the work list.cost: lowLow engineering cost to implement.type-code-health

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions