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 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 12:49:05 +02:00
co-authored by Claude
parent 9385dd253a
commit 05948b41a6
4 changed files with 5 additions and 9 deletions
@@ -46,7 +46,7 @@ class ContainersDatasource {
final response = await _dio.get<String>(
'/infrastructure/containers/$id/logs',
queryParameters: {
if (tail != null) 'tail': tail,
'tail': ?tail,
'timestamps': timestamps,
},
);
@@ -30,10 +30,7 @@ class _DashboardContentState extends ConsumerState<DashboardContent> {
/// 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<DashboardContent> {
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}');
}
+1 -1
View File
@@ -150,7 +150,7 @@ class EntitySection extends StatelessWidget {
),
),
),
if (trailing != null) trailing!,
?trailing,
],
),
const SizedBox(height: 8),
@@ -395,7 +395,7 @@ void main() {
const mode = DataGridDataMode.infinite();
expect(mode, isA<InfiniteDataMode>());
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);
});
});
}