Added test to find unmatched < and > for conditional typos. (#6415)

This commit is contained in:
Yair Morgenstern 2022-03-23 20:04:16 +02:00 committed by GitHub
parent 9721b38f6b
commit f013d400b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -346,12 +346,16 @@ class Ruleset {
val equalUniques = val equalUniques =
similarUniques.filter { it.placeholderText == unique.placeholderText } similarUniques.filter { it.placeholderText == unique.placeholderText }
return when { return when {
equalUniques.isNotEmpty() -> { // Malformed conditional
// This should only ever happen if a bug is or has been introduced that prevents Unique.type from being set for a valid UniqueType, I think.\ unique.text.count { it=='<' } != unique.text.count { it=='>' } ->listOf(
listOf(RulesetError( RulesetError("$name's unique \"${unique.text}\" contains mismatched conditional braces!",
"$name's unique \"${unique.text}\" looks like it should be fine, but for some reason isn't recognized.", RulesetErrorSeverity.Warning))
RulesetErrorSeverity.OK))
} // This should only ever happen if a bug is or has been introduced that prevents Unique.type from being set for a valid UniqueType, I think.\
equalUniques.isNotEmpty() -> listOf(RulesetError(
"$name's unique \"${unique.text}\" looks like it should be fine, but for some reason isn't recognized.",
RulesetErrorSeverity.OK))
similarUniques.isNotEmpty() -> { similarUniques.isNotEmpty() -> {
val text = val text =
"$name's unique \"${unique.text}\" looks like it may be a misspelling of:\n" + "$name's unique \"${unique.text}\" looks like it may be a misspelling of:\n" +
@ -366,7 +370,7 @@ class Ruleset {
}.prependIndent("\t") }.prependIndent("\t")
listOf(RulesetError(text, RulesetErrorSeverity.OK)) listOf(RulesetError(text, RulesetErrorSeverity.OK))
} }
RulesetCache.modCheckerAllowUntypedUniques -> return emptyList() RulesetCache.modCheckerAllowUntypedUniques -> emptyList()
else -> listOf(RulesetError( else -> listOf(RulesetError(
"$name's unique \"${unique.text}\" not found in Unciv's unique types.", "$name's unique \"${unique.text}\" not found in Unciv's unique types.",
RulesetErrorSeverity.OK)) RulesetErrorSeverity.OK))