Run `dcm check-unused-code` on each PR to find unused code. (#9908)
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index d1fd75d..125a7ca 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -79,9 +79,13 @@
echo "$(dcm --version)"
- name: Setup Dart SDK
uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
- - name: Run DCM on root
+ - name: Run dcm analyze on root
run: |
dcm analyze packages/devtools_app packages/devtools_app_shared packages/devtools_extensions packages/devtools_shared packages/devtools_test
+ - name: Run dcm checks on packages
+ # TODO(https://github.com/flutter/devtools/issues/9906): run on all DevTools packages.
+ run: |
+ dcm check-unused-code packages/devtools_app --exclude-public-api
test-packages:
name: ${{ matrix.os }} ${{ matrix.package }} test
diff --git a/analysis_options.yaml b/analysis_options.yaml
index f59d8d0..d6dd068 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -156,6 +156,21 @@
maximum-nesting-level: 5
metrics-exclude:
- test/**
+ exclude:
+ unused-code:
+ # TODO(https://github.com/dart-lang/sdk/issues/63864): clean up these
+ # paths once this issue is fixed. These paths are currently relative to
+ # devtools_app/.
+ # TODO(https://github.com/flutter/devtools/issues/9906) remove these
+ # excludes as findings are resolved.
+ - integration_test/**
+ - lib/src/extensions/**
+ - lib/src/framework/**
+ - lib/src/screens/**
+ - lib/src/service/**
+ - lib/src/shared/**
+ - lib/src/standalone_ui/**
+ - test/**
rules:
# - arguments-ordering Too strict
# - avoid-banned-imports # TODO(polina-c): add configuration
diff --git a/packages/devtools_app/lib/src/app.dart b/packages/devtools_app/lib/src/app.dart
index e51ec18..b948d84 100644
--- a/packages/devtools_app/lib/src/app.dart
+++ b/packages/devtools_app/lib/src/app.dart
@@ -242,12 +242,11 @@
// Provide the appropriate page route.
if (pages.containsKey(page)) {
Widget widget = pages[page]!(context, page, params, state);
- assert(() {
+ if (kDebugMode) {
widget = _AlternateCheckedModeBanner(
builder: (context) => pages[page]!(context, page, params, state),
);
- return true;
- }());
+ }
return MaterialPage(child: widget);
}
@@ -618,7 +617,9 @@
///
/// This avoids issues with widgets in the appbar being hidden by the banner
/// in a web or desktop app.
+// ignore: unused-code, TODO(https://github.com/flutter/devtools/issues/9907): false positive.
class _AlternateCheckedModeBanner extends StatelessWidget {
+ // ignore: unused-code, TODO(https://github.com/flutter/devtools/issues/9907): false positive.
const _AlternateCheckedModeBanner({required this.builder});
final WidgetBuilder builder;