Fix CA1310, CA1311

This commit is contained in:
RoosterDragon
2023-03-12 15:44:49 +00:00
committed by Matthias Mailänder
parent d83e579dfe
commit 285443f10f
43 changed files with 80 additions and 67 deletions

View File

@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Lint
if (sequenceReference.Prefix)
{
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence)))
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence, StringComparison.Ordinal)))
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
}
else if (!sequences.HasSequence(i, sequence))
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Lint
if (sequenceReference.Prefix)
{
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
if (!sequences.Sequences(image).Any(s => s.StartsWith(sequence)))
if (!sequences.Sequences(image).Any(s => s.StartsWith(sequence, StringComparison.Ordinal)))
emitWarning($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{image}`.");
}
else if (!sequences.HasSequence(image, sequence))

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Lint
static string NormalizeName(string key)
{
var name = key.Split('@')[0];
if (name.StartsWith("-", StringComparison.Ordinal))
if (name.StartsWith('-'))
return name[1..];
return name;
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var t in actor.Value.Nodes)
{
// Removals can never define children or values.
if (t.Key.StartsWith("-", StringComparison.Ordinal))
if (t.Key.StartsWith('-'))
{
if (t.Value.Nodes.Length > 0)
emitError($"{t.Location} `{t.Key}` defines child nodes, which are not valid for removals.");

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Lint
static string NormalizeName(string key)
{
var name = key.Split('@')[0];
if (name.StartsWith("-", StringComparison.Ordinal))
if (name.StartsWith('-'))
return name[1..];
return name;
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var field in weapon.Value.Nodes)
{
// Removals can never define children or values
if (field.Key.StartsWith("-", StringComparison.Ordinal))
if (field.Key.StartsWith('-'))
{
if (field.Value.Nodes.Length > 0)
emitError($"{field.Location} `{field.Key}` defines child nodes, which is not valid for removals.");

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Lint
var bi = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
if (bi != null)
foreach (var prereq in bi.Prerequisites)
if (!prereq.StartsWith("~disabled") && !providedPrereqs.Contains(prereq.Replace("!", "").Replace("~", "")))
if (!prereq.StartsWith("~disabled", StringComparison.Ordinal) && !providedPrereqs.Contains(prereq.Replace("!", "").Replace("~", "")))
emitError($"Buildable actor `{actorInfo.Key}` has prereq `{prereq}` not provided by anything.");
}
catch (InvalidOperationException e)