From 7ee14396b1f1f96ed0472b5949ce82a7f9313276 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Nov 2026 15:38:13 +0100 Subject: server: make local variables final (prefer_final_locals) 270 locals across 52 files. Six of them were declared with an unnecessarily nullable type (ModifierDeck? / LootDeckModel?) although the initializer is non-nullable; non-final locals were silently flow-promoted to the initializer's type, but final locals are not, so the nullability is dropped where it was wrong. --- server/lib/core/models/scenario.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'server/lib/core/models/scenario.dart') diff --git a/server/lib/core/models/scenario.dart b/server/lib/core/models/scenario.dart index 18cd709..0e3d97e 100644 --- a/server/lib/core/models/scenario.dart +++ b/server/lib/core/models/scenario.dart @@ -164,14 +164,14 @@ class ScenarioModel { Map data, RoomsModel? rooms, ) { - List monsterList = []; + final List monsterList = []; if (data.containsKey('monsters')) { final monsters = (data['monsters'] as List).cast(); for (final monster in monsters) { monsterList.add(monster); } } - List rulesList = []; + final List rulesList = []; if (data.containsKey('special')) { final specialRules = (data['special'] as List) .cast>(); @@ -188,10 +188,10 @@ class ScenarioModel { initMessage = data['initialMessage']; } - List sectionList = []; + final List sectionList = []; if (rooms != null) { - List names = []; + final List names = []; for (final u in rooms.roomData) { if (names.contains(u.name)) { print("duplicate ${u.name} in ${rooms.scenarioName}"); @@ -218,14 +218,14 @@ class ScenarioModel { } else { //it might be a bit silly that room data and section data is separate //merge if has already - int splitIndex = 0; + final int splitIndex = 0; //would be nice to know which is solo scenario - ScenarioModel? section = sectionList.firstWhereOrNull( + final ScenarioModel? section = sectionList.firstWhereOrNull( (element) => element.name == key.split(" ")[splitIndex], ); if (section != null) { //merge - ScenarioModel model = ScenarioModel.sectionFromJson( + final ScenarioModel model = ScenarioModel.sectionFromJson( key, sections[key], rooms, @@ -261,14 +261,14 @@ class ScenarioModel { Map data, RoomsModel? rooms, ) { - List monsterList = []; + final List monsterList = []; if (data.containsKey('monsters')) { final monsters = (data['monsters'] as List).cast(); for (final monster in monsters) { monsterList.add(monster); } } - List rulesList = []; + final List rulesList = []; if (data.containsKey('special')) { final specialRules = (data['special'] as List) .cast>(); @@ -282,7 +282,7 @@ class ScenarioModel { } //find right room - List? standees = rooms?.roomData + final List? standees = rooms?.roomData .firstWhereOrNull( (element) => element.name == -- cgit v1.3.1