From 6060c43bee23ebae41edbe914ba991ebf0a96924 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Nov 2026 18:55:57 +0100 Subject: server: type the JSON parsing boundaries (avoid_dynamic_calls) Give the decoded JSON values a static type before use: cast the monster-ability card list to List> (and the graphic extras to Map entries), the summon payload to Map, room data lists/maps explicitly, and deck card lists to Map loop variables. The test assertions on the settings payload get the same treatment. Also drops two stale ignore comments (wrong lint code) and a redundant nested assignment. --- server/test/net/settings_test.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server/test') diff --git a/server/test/net/settings_test.dart b/server/test/net/settings_test.dart index 677af11..900039b 100644 --- a/server/test/net/settings_test.dart +++ b/server/test/net/settings_test.dart @@ -97,8 +97,8 @@ void main() { final aliceGot = await table.alice.nextOf('settings'); final bobGot = await table.bob.nextOf('settings'); - expect(aliceGot['settings']['hideLootDeck'], isTrue); - expect(bobGot['settings']['hideLootDeck'], isTrue); + expect((aliceGot['settings'] as Map)['hideLootDeck'], isTrue); + expect((bobGot['settings'] as Map)['hideLootDeck'], isTrue); expect(getIt().hideLootDeck, isTrue); // A reconnecting client sees it in the welcome too. @@ -335,7 +335,7 @@ void main() { table.alice.send(Protocol.saveMessage('alpha')); final saved = await table.alice.nextOf('settings'); - expect(saved['settings']['saves'], ['alpha']); + expect((saved['settings'] as Map)['saves'], ['alpha']); expect(getIt().saves.keys, contains('alpha')); // Change the state: add a monster (index 2). @@ -377,7 +377,7 @@ void main() { // Delete the save; loading it after is rejected. table.alice.send(Protocol.deleteSaveMessage('alpha')); final deleted = await table.alice.nextOf('settings'); - expect(deleted['settings']['saves'], isEmpty); + expect((deleted['settings'] as Map)['saves'], isEmpty); expect(getIt().saves.keys, isEmpty); table.alice.send(Protocol.loadSaveMessage('alpha')); @@ -402,7 +402,7 @@ void main() { // No error: deleting an unknown save is a silent no-op (the // reference's deleteSave just removes from the map). final settings = await table.alice.nextOf('settings'); - expect(settings['settings']['saves'], isEmpty); + expect((settings['settings'] as Map)['saves'], isEmpty); } finally { await table.teardown(); } @@ -419,7 +419,7 @@ void main() { Protocol.saveCharacterMessage('Blinky backup', 'Blinkblade'), ); final saved = await table.alice.nextOf('settings'); - final characterSaves = saved['settings']['characterSaves'] as List; + final characterSaves = (saved['settings'] as Map)['characterSaves'] as List; expect( characterSaves, [{ @@ -452,7 +452,7 @@ void main() { Protocol.deleteCharacterSaveMessage('Blinky backup\nBlinkblade'), ); final deleted = await table.alice.nextOf('settings'); - expect(deleted['settings']['characterSaves'], isEmpty); + expect((deleted['settings'] as Map)['characterSaves'], isEmpty); table.alice.send( Protocol.loadCharacterSaveMessage('Blinky backup\nBlinkblade'), -- cgit v1.3.1