flutter / flutter/devtools

`dcm check-unused-code` false positives

Open
#9,907 6 comments 1 reaction 0 assignees View on GitHub
a: quality cost: low P2
Dominant language
Dart
Stars
1.7k
Forks
404
Avg merge
6d 17h
Merged PRs (30d)
18

Description

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 https://github.com/flutter/devtools/issues/9906).

@incendial

Contributor guide

Open the contributing guide

Research direction

Start by running `dcm check-unused-code packages/devtools_app/ --exclude-public-api` and inspect the reported Dart files, including `extent_delegate_utils.dart`, `_controller_web.dart`, `home_screen.dart`, `app.dart`, and `_perfetto_controller_web.dart`. Trace the listed fields, methods, and classes through their assert usages, then verify that genuine uses are no longer reported while actual unused code still is.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.