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/line_builder/stat_applier.dart | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'server/lib/core/line_builder') diff --git a/server/lib/core/line_builder/stat_applier.dart b/server/lib/core/line_builder/stat_applier.dart index 436e7ef..e706a73 100644 --- a/server/lib/core/line_builder/stat_applier.dart +++ b/server/lib/core/line_builder/stat_applier.dart @@ -49,7 +49,7 @@ class StatApplier { final normalTokens = _getStatTokens(monster, false); final eliteTokens = _getStatTokens(monster, true); - RegExp regExpNumbers = RegExp(r'^[\d ()xCL/*+-]+$'); + final RegExp regExpNumbers = RegExp(r'^[\d ()xCL/*+-]+$'); //first pass fix values only String lastToken = ""; //turn this into move or attack or whatever, then apply correct monster stat @@ -81,11 +81,11 @@ class StatApplier { ' ') //supposing there is always a leading whitespace to any formula ) { String formula = line[i]; - int startIndex = i; + final int startIndex = i; int endIndex = i; for (int j = i + 1; j < lineInput.length; j++) { - String val = lineInput[j]; + final String val = lineInput[j]; if (val.contains(regExpNumbers) || val == "d") { if (val != ' ') formula += val; endIndex = j; @@ -172,7 +172,7 @@ class StatApplier { } for (String item in data.attributes) { //remove size modifiers (only used for immobilize since it's so long it overflows.) - String sizeMod = (item.substring(0, 1)); + final String sizeMod = (item.substring(0, 1)); if (sizeMod == "^" || sizeMod == "*" && item.length > 1) { item = item.substring(1); } @@ -181,14 +181,14 @@ class StatApplier { //parse item and then parse number; for (int i = 1; i < item.length; i++) { if (item[i] == '%') { - String token = item.substring(1, i); + final String token = item.substring(1, i); int number = 0; if (i != item.length - 1) { for (int j = i + _kTokenEndOffset; j < item.length; j++) { if (item[j] == ' ' || j == item.length - 1) { //need to find end of nr and ignore the rest - String nr = item.substring(i + 1, j + 1); - int? res = StatCalculator.calculateFormula(nr); + final String nr = item.substring(i + 1, j + 1); + final int? res = StatCalculator.calculateFormula(nr); if (res != null) { number = res; } else { @@ -233,15 +233,15 @@ class StatApplier { return [line]; } - List retVal = []; - List tokens = []; - List eTokens = []; + final List retVal = []; + final List tokens = []; + final List eTokens = []; int normalValue = 0; int eliteValue = 0; bool skipCalculation = false; //in case un-calculable final level = monster.type.levels[monster.level]; - MonsterStatsModel? normal = level.boss ?? level.normal; - MonsterStatsModel? elite = level.elite; + final MonsterStatsModel? normal = level.boss ?? level.normal; + final MonsterStatsModel? elite = level.elite; if (lastToken == "attack") { if (normal == null) return []; int? calc = StatCalculator.calculateFormula(normal.attack); @@ -257,7 +257,7 @@ class StatApplier { } } - RegExp regEx = RegExp( + final RegExp regEx = RegExp( r"(?=.*[a-z])", ); //not sure why I do this. only letters? for (final item in normalTokens.keys) { @@ -296,8 +296,8 @@ class StatApplier { eliteValue = StatCalculator.calculateFormula(elite.move) ?? 0; } } else if (lastToken == "shield") { - int? value = normalTokens["shield"]; - int? eValue = eliteTokens["shield"]; + final int? value = normalTokens["shield"]; + final int? eValue = eliteTokens["shield"]; if (elite != null && eValue != null) { eliteValue = eValue; } @@ -305,8 +305,8 @@ class StatApplier { normalValue = value; } } else if (lastToken == "retaliate") { - int? value = normalTokens["retaliate"]; - int? eValue = eliteTokens["retaliate"]; + final int? value = normalTokens["retaliate"]; + final int? eValue = eliteTokens["retaliate"]; if (elite != null && eValue != null) { eliteValue = eValue; } @@ -336,8 +336,8 @@ class StatApplier { for (final item in tokens) { newStartOfLine += "|$item"; //add nr if applicable - String key = item.substring(1, item.length - 1); - int value = normalTokens[key] ?? 0; + final String key = item.substring(1, item.length - 1); + final int value = normalTokens[key] ?? 0; if (value > 0) { newStartOfLine += "$value"; } @@ -366,8 +366,8 @@ class StatApplier { eliteString += "|$item"; //add nr if applicable - String key = item.substring(1, item.length - 1); - int value = eliteTokens[key]!; + final String key = item.substring(1, item.length - 1); + final int value = eliteTokens[key]!; if (value > 0) { eliteString += "$value"; } @@ -377,7 +377,7 @@ class StatApplier { retVal.add(newStartOfLine); } if (endIndex < line.length) { - String leftOver = + final String leftOver = "!$sizeModifier${line.substring(endIndex + 1, line.length)}"; retVal.add(leftOver); -- cgit v1.3.1