Skip to content

Commit 1c7e423

Browse files
Run dcm check-unused-code on each PR to find unused code. (#9908)
1 parent cc4971d commit 1c7e423

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

.github/workflows/build.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ jobs:
7979
echo "$(dcm --version)"
8080
- name: Setup Dart SDK
8181
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
82-
- name: Run DCM on root
82+
- name: Run dcm analyze on root
8383
run: |
8484
dcm analyze packages/devtools_app packages/devtools_app_shared packages/devtools_extensions packages/devtools_shared packages/devtools_test
85+
- name: Run dcm checks on packages
86+
# TODO(https://github.com/flutter/devtools/issues/9906): run on all DevTools packages.
87+
run: |
88+
dcm check-unused-code packages/devtools_app --exclude-public-api
8589
8690
test-packages:
8791
name: ${{ matrix.os }} ${{ matrix.package }} test

analysis_options.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ dart_code_metrics:
156156
maximum-nesting-level: 5
157157
metrics-exclude:
158158
- test/**
159+
exclude:
160+
unused-code:
161+
# TODO(https://github.com/dart-lang/sdk/issues/63864): clean up these
162+
# paths once this issue is fixed. These paths are currently relative to
163+
# devtools_app/.
164+
# TODO(https://github.com/flutter/devtools/issues/9906) remove these
165+
# excludes as findings are resolved.
166+
- integration_test/**
167+
- lib/src/extensions/**
168+
- lib/src/framework/**
169+
- lib/src/screens/**
170+
- lib/src/service/**
171+
- lib/src/shared/**
172+
- lib/src/standalone_ui/**
173+
- test/**
159174
rules:
160175
# - arguments-ordering Too strict
161176
# - avoid-banned-imports # TODO(polina-c): add configuration

packages/devtools_app/lib/src/app.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,11 @@ class DevToolsAppState extends State<DevToolsApp> with AutoDisposeMixin {
242242
// Provide the appropriate page route.
243243
if (pages.containsKey(page)) {
244244
Widget widget = pages[page]!(context, page, params, state);
245-
assert(() {
245+
if (kDebugMode) {
246246
widget = _AlternateCheckedModeBanner(
247247
builder: (context) => pages[page]!(context, page, params, state),
248248
);
249-
return true;
250-
}());
249+
}
251250
return MaterialPage(child: widget);
252251
}
253252

@@ -618,7 +617,9 @@ typedef UrlParametersBuilder =
618617
///
619618
/// This avoids issues with widgets in the appbar being hidden by the banner
620619
/// in a web or desktop app.
620+
// ignore: unused-code, TODO(https://github.com/flutter/devtools/issues/9907): false positive.
621621
class _AlternateCheckedModeBanner extends StatelessWidget {
622+
// ignore: unused-code, TODO(https://github.com/flutter/devtools/issues/9907): false positive.
622623
const _AlternateCheckedModeBanner({required this.builder});
623624
final WidgetBuilder builder;
624625

0 commit comments

Comments
 (0)