From 05948b41a6a2c6b52f532f43874000d732d8339d Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Tue, 11 Aug 2026 12:49:05 +0200 Subject: [PATCH] fix(analysis): clear the five findings blocking the pre-push gate flutter analyze exits non-zero on info-level findings too, so all five had to go for `make pre-push` to pass. Four were mechanical. The fifth was not. envApiUser was reported as an unused declaration. Removing it revealed that the field behind it, _envApiUser, was then unused as well -- and the pair turns out to be a closed loop nothing could enter: the getter is public but sits on _DashboardContentState, a private class, so no caller outside this file could ever have reached it. The field was written once per session and never read. The debugPrint next to it logs envData.user directly, so the logging the comment describes never depended on the stored copy. Field, getter and assignment removed; _hasLoggedEnvUser stays, because it genuinely guards the log-once. Deleting the first warning exposing the second is the useful part: unused_field could not fire while a dead getter was "using" it. Dead code hides dead code. The two `if (x != null) x` collection entries become null-aware elements, which is the same intent spelled the way the SDK now expects. The two casts in data_grid_test were the second cast of a pair -- `mode as InfiniteDataMode` on the preceding line already promotes the local. flutter analyze: No issues found. The edited test file still passes all 37. Note the gate still prints "not gated here yet: test (T-56)" -- analysis is green, tests remain unwired, and that is deliberately left visible. Co-Authored-By: Claude --- .../containers/data/datasources/containers_datasource.dart | 2 +- .../front_hall/presentation/widgets/dashboard_content.dart | 6 +----- lib/shared/widgets/entity_page.dart | 2 +- test/shared/components/data_grid/data_grid_test.dart | 4 ++-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/features/control_room/containers/data/datasources/containers_datasource.dart b/lib/features/control_room/containers/data/datasources/containers_datasource.dart index c894e75..e6b06e5 100644 --- a/lib/features/control_room/containers/data/datasources/containers_datasource.dart +++ b/lib/features/control_room/containers/data/datasources/containers_datasource.dart @@ -46,7 +46,7 @@ class ContainersDatasource { final response = await _dio.get( '/infrastructure/containers/$id/logs', queryParameters: { - if (tail != null) 'tail': tail, + 'tail': ?tail, 'timestamps': timestamps, }, ); diff --git a/lib/features/front_hall/presentation/widgets/dashboard_content.dart b/lib/features/front_hall/presentation/widgets/dashboard_content.dart index 2148172..b510be2 100644 --- a/lib/features/front_hall/presentation/widgets/dashboard_content.dart +++ b/lib/features/front_hall/presentation/widgets/dashboard_content.dart @@ -30,10 +30,7 @@ class _DashboardContentState extends ConsumerState { /// Tracks if we've logged the environment API user (log once per session) static bool _hasLoggedEnvUser = false; - static String? _envApiUser; - /// Get the environment API user (available after first load) - static String? get envApiUser => _envApiUser; @override void initState() { @@ -157,9 +154,8 @@ class _DashboardContentState extends ConsumerState { const SizedBox(height: 8), environmentAsync.when( data: (envData) { - // Store and log user once per session + // Log the user once per session if (!_hasLoggedEnvUser && envData.user != null) { - _envApiUser = envData.user; _hasLoggedEnvUser = true; debugPrint('Environment API user: ${envData.user}'); } diff --git a/lib/shared/widgets/entity_page.dart b/lib/shared/widgets/entity_page.dart index ae0c201..faa3bea 100644 --- a/lib/shared/widgets/entity_page.dart +++ b/lib/shared/widgets/entity_page.dart @@ -150,7 +150,7 @@ class EntitySection extends StatelessWidget { ), ), ), - if (trailing != null) trailing!, + ?trailing, ], ), const SizedBox(height: 8), diff --git a/test/shared/components/data_grid/data_grid_test.dart b/test/shared/components/data_grid/data_grid_test.dart index fd9f142..4163b82 100644 --- a/test/shared/components/data_grid/data_grid_test.dart +++ b/test/shared/components/data_grid/data_grid_test.dart @@ -395,7 +395,7 @@ void main() { const mode = DataGridDataMode.infinite(); expect(mode, isA()); expect((mode as InfiniteDataMode).initialLoad, 50); - expect((mode as InfiniteDataMode).loadMoreThreshold, 10); + expect(mode.loadMoreThreshold, 10); }); test('infinite mode with custom values', () { @@ -404,7 +404,7 @@ void main() { loadMoreThreshold: 20, ); expect((mode as InfiniteDataMode).initialLoad, 100); - expect((mode as InfiniteDataMode).loadMoreThreshold, 20); + expect(mode.loadMoreThreshold, 20); }); }); }