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 =
similarUniques.filter { it.placeholderText == unique.placeholderText }
return when {
equalUniques.isNotEmpty() -> {
// 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.\
listOf(RulesetError(
"$name's unique \"${unique.text}\" looks like it should be fine, but for some reason isn't recognized.",
RulesetErrorSeverity.OK))
}
// Malformed conditional
unique.text.count { it=='<' } != unique.text.count { it=='>' } ->listOf(
RulesetError("$name's unique \"${unique.text}\" contains mismatched conditional braces!",
RulesetErrorSeverity.Warning))
// 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() -> {
val text =
"$name's unique \"${unique.text}\" looks like it may be a misspelling of:\n" +
@ -366,7 +370,7 @@ class Ruleset {
}.prependIndent("\t")
listOf(RulesetError(text, RulesetErrorSeverity.OK))
}
RulesetCache.modCheckerAllowUntypedUniques -> return emptyList()
RulesetCache.modCheckerAllowUntypedUniques -> emptyList()
else -> listOf(RulesetError(
"$name's unique \"${unique.text}\" not found in Unciv's unique types.",
RulesetErrorSeverity.OK))