Add punctuation to lint comments
This commit is contained in:
committed by
Matthias Mailänder
parent
d9d8c23c63
commit
3188532e59
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var minAngle = missile.MinimumLaunchAngle.Angle;
|
var minAngle = missile.MinimumLaunchAngle.Angle;
|
||||||
var maxAngle = missile.MaximumLaunchAngle.Angle;
|
var maxAngle = missile.MaximumLaunchAngle.Angle;
|
||||||
|
|
||||||
// If both angles are identical, we only need to test one of them
|
// If both angles are identical, we only need to test one of them.
|
||||||
var testMaxAngle = minAngle != maxAngle;
|
var testMaxAngle = minAngle != maxAngle;
|
||||||
CheckLaunchAngles(weaponInfo.Key, minAngle, testMaxAngle, maxAngle, emitError);
|
CheckLaunchAngles(weaponInfo.Key, minAngle, testMaxAngle, maxAngle, emitError);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var minAngle = bullet.LaunchAngle[0].Angle;
|
var minAngle = bullet.LaunchAngle[0].Angle;
|
||||||
var maxAngle = bullet.LaunchAngle.Length > 1 ? bullet.LaunchAngle[1].Angle : minAngle;
|
var maxAngle = bullet.LaunchAngle.Length > 1 ? bullet.LaunchAngle[1].Angle : minAngle;
|
||||||
|
|
||||||
// If both angles are identical, we only need to test one of them
|
// If both angles are identical, we only need to test one of them.
|
||||||
var testMaxAngle = minAngle != maxAngle;
|
var testMaxAngle = minAngle != maxAngle;
|
||||||
CheckLaunchAngles(weaponInfo.Key, minAngle, testMaxAngle, maxAngle, emitError);
|
CheckLaunchAngles(weaponInfo.Key, minAngle, testMaxAngle, maxAngle, emitError);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
public void Run(Action<string> emitError, Action<string> emitWarning, ModData modData)
|
public void Run(Action<string> emitError, Action<string> emitWarning, ModData modData)
|
||||||
{
|
{
|
||||||
// Build the list of valid hotkey names
|
// Build the list of valid hotkey names.
|
||||||
var namedKeys = modData.Hotkeys.Definitions.Select(d => d.Name).ToArray();
|
var namedKeys = modData.Hotkeys.Definitions.Select(d => d.Name).ToArray();
|
||||||
|
|
||||||
// Build the list of widget keys to validate
|
// Build the list of widget keys to validate.
|
||||||
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
|
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
|
||||||
.SelectMany(w => Utility.GetFields(w)
|
.SelectMany(w => Utility.GetFields(w)
|
||||||
.Where(f => f.FieldType == typeof(HotkeyReference))
|
.Where(f => f.FieldType == typeof(HotkeyReference))
|
||||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check runtime-defined hotkey names
|
// Check runtime-defined hotkey names.
|
||||||
var widgetType = node.Key.Split('@')[0];
|
var widgetType = node.Key.Split('@')[0];
|
||||||
if (customLintMethods.TryGetValue(widgetType, out var checkMethods))
|
if (customLintMethods.TryGetValue(widgetType, out var checkMethods))
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
emitError($"{node.Location} refers to a Key named `{name}` that does not exist");
|
emitError($"{node.Location} refers to a Key named `{name}` that does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logic classes can declare the data key names that specify hotkeys
|
// Logic classes can declare the data key names that specify hotkeys.
|
||||||
if (node.Key == "Logic" && node.Value.Nodes.Count > 0)
|
if (node.Key == "Logic" && node.Value.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
var typeNames = FieldLoader.GetValue<string[]>(node.Key, node.Value.Value);
|
var typeNames = FieldLoader.GetValue<string[]>(node.Key, node.Value.Value);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
// Catch TypeDictionary errors
|
// Catch TypeDictionary errors.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var count = actorInfo.Value.TraitInfos<IDefaultVisibilityInfo>().Count();
|
var count = actorInfo.Value.TraitInfos<IDefaultVisibilityInfo>().Count();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
// Catch TypeDictionary errors
|
// Catch TypeDictionary errors.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var health = actorInfo.Value.TraitInfoOrDefault<IHealthInfo>();
|
var health = actorInfo.Value.TraitInfoOrDefault<IHealthInfo>();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
.Select(p => p.Name)
|
.Select(p => p.Name)
|
||||||
.ToHashSet();
|
.ToHashSet();
|
||||||
|
|
||||||
// Check for actors that require specific owners
|
// Check for actors that require specific owners.
|
||||||
var actorsWithRequiredOwner = map.Rules.Actors
|
var actorsWithRequiredOwner = map.Rules.Actors
|
||||||
.Where(a => a.Value.HasTraitInfo<RequiresSpecificOwnersInfo>())
|
.Where(a => a.Value.HasTraitInfo<RequiresSpecificOwnersInfo>())
|
||||||
.ToDictionary(a => a.Key, a => a.Value.TraitInfo<RequiresSpecificOwnersInfo>());
|
.ToDictionary(a => a.Key, a => a.Value.TraitInfo<RequiresSpecificOwnersInfo>());
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
tilesetPalettes.Add(tilesetPalette);
|
tilesetPalettes.Add(tilesetPalette);
|
||||||
|
|
||||||
// Only add the basic palette name once
|
// Only add the basic palette name once.
|
||||||
if (!palettes.Contains(value))
|
if (!palettes.Contains(value))
|
||||||
palettes.Add(value);
|
palettes.Add(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
// Catch TypeDictionary errors
|
// Catch TypeDictionary errors.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var ios = actorInfo.Value.TraitInfoOrDefault<IOccupySpaceInfo>();
|
var ios = actorInfo.Value.TraitInfoOrDefault<IOccupySpaceInfo>();
|
||||||
|
|||||||
@@ -39,25 +39,25 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var factions = rules.Actors[SystemActors.World].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
var factions = rules.Actors[SystemActors.World].TraitInfos<FactionInfo>().Select(f => f.InternalName).ToArray();
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
// Catch TypeDictionary errors
|
// Catch TypeDictionary errors.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var images = new HashSet<string>();
|
var images = new HashSet<string>();
|
||||||
|
|
||||||
// Actors may have 0 or 1 RenderSprites traits
|
// Actors may have 0 or 1 RenderSprites traits.
|
||||||
var renderInfo = actorInfo.Value.TraitInfoOrDefault<RenderSpritesInfo>();
|
var renderInfo = actorInfo.Value.TraitInfoOrDefault<RenderSpritesInfo>();
|
||||||
if (renderInfo != null)
|
if (renderInfo != null)
|
||||||
{
|
{
|
||||||
images.Add(renderInfo.GetImage(actorInfo.Value, null).ToLowerInvariant());
|
images.Add(renderInfo.GetImage(actorInfo.Value, null).ToLowerInvariant());
|
||||||
|
|
||||||
// Some actors define faction-specific artwork
|
// Some actors define faction-specific artwork.
|
||||||
foreach (var faction in factions)
|
foreach (var faction in factions)
|
||||||
images.Add(renderInfo.GetImage(actorInfo.Value, faction).ToLowerInvariant());
|
images.Add(renderInfo.GetImage(actorInfo.Value, faction).ToLowerInvariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||||
{
|
{
|
||||||
// Remove the "Info" suffix
|
// Remove the "Info" suffix.
|
||||||
var traitName = traitInfo.GetType().Name;
|
var traitName = traitInfo.GetType().Name;
|
||||||
traitName = traitName.Remove(traitName.Length - 4);
|
traitName = traitName.Remove(traitName.Length - 4);
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (sequenceReference == null)
|
if (sequenceReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Some sequences may specify their own Image override
|
// Some sequences may specify their own Image override.
|
||||||
IEnumerable<string> sequenceImages = images;
|
IEnumerable<string> sequenceImages = images;
|
||||||
if (!string.IsNullOrEmpty(sequenceReference.ImageReference))
|
if (!string.IsNullOrEmpty(sequenceReference.ImageReference))
|
||||||
{
|
{
|
||||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
if (sequenceReference.Prefix)
|
if (sequenceReference.Prefix)
|
||||||
{
|
{
|
||||||
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references
|
// 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)))
|
||||||
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
|
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
if (sequenceReference == null)
|
if (sequenceReference == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// All weapon sequences must specify their corresponding image
|
// All weapon sequences must specify their corresponding image.
|
||||||
var image = (string)fields.First(f => f.Name == sequenceReference.ImageReference).GetValue(projectileInfo);
|
var image = (string)fields.First(f => f.Name == sequenceReference.ImageReference).GetValue(projectileInfo);
|
||||||
if (string.IsNullOrEmpty(image))
|
if (string.IsNullOrEmpty(image))
|
||||||
{
|
{
|
||||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
if (sequenceReference.Prefix)
|
if (sequenceReference.Prefix)
|
||||||
{
|
{
|
||||||
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references
|
// 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)))
|
||||||
emitWarning($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{image}`.");
|
emitWarning($"Weapon type `{weaponInfo.Key}` projectile field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{image}`.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
// Catch TypeDictionary errors
|
// Catch TypeDictionary errors.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var buildable = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
var buildable = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
if (!Enum.TryParse(actorInfo.Key, true, out SystemActors systemActor) || !traitLocation.SystemActors.HasFlag(systemActor))
|
if (!Enum.TryParse(actorInfo.Key, true, out SystemActors systemActor) || !traitLocation.SystemActors.HasFlag(systemActor))
|
||||||
{
|
{
|
||||||
// Remove the "Info" suffix
|
// Remove the "Info" suffix.
|
||||||
var traitName = traitInfo.GetType().Name;
|
var traitName = traitInfo.GetType().Name;
|
||||||
traitName = traitName.Remove(traitName.Length - 4);
|
traitName = traitName.Remove(traitName.Length - 4);
|
||||||
var locations = traitLocation.SystemActors.ToString().Replace(", ", " or ");
|
var locations = traitLocation.SystemActors.ToString().Replace(", ", " or ");
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
foreach (var entry in result.Entries)
|
foreach (var entry in result.Entries)
|
||||||
{
|
{
|
||||||
// Don't flag definitions referenced (only) within the .ftl definitions as unused
|
// Don't flag definitions referenced (only) within the .ftl definitions as unused.
|
||||||
if (entry.GetType() == typeof(AstTerm))
|
if (entry.GetType() == typeof(AstTerm))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
foreach (var t in actor.Value.Nodes)
|
foreach (var t in actor.Value.Nodes)
|
||||||
{
|
{
|
||||||
// Removals can never define children or values
|
// Removals can never define children or values.
|
||||||
if (t.Key.StartsWith("-", StringComparison.Ordinal))
|
if (t.Key.StartsWith("-", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
if (t.Value.Nodes.Count > 0)
|
if (t.Value.Nodes.Count > 0)
|
||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
var traitName = NormalizeName(t.Key);
|
var traitName = NormalizeName(t.Key);
|
||||||
|
|
||||||
// Inherits can never define children
|
// Inherits can never define children.
|
||||||
if (traitName == "Inherits")
|
if (traitName == "Inherits")
|
||||||
{
|
{
|
||||||
if (t.Value.Nodes.Count > 0)
|
if (t.Value.Nodes.Count > 0)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
void Run(Action<string> emitError, List<MiniYamlNode> nodes)
|
void Run(Action<string> emitError, List<MiniYamlNode> nodes)
|
||||||
{
|
{
|
||||||
// Build a list of all inheritance relationships
|
// Build a list of all inheritance relationships.
|
||||||
var inheritsMap = new Dictionary<string, List<string>>();
|
var inheritsMap = new Dictionary<string, List<string>>();
|
||||||
foreach (var actorNode in nodes)
|
foreach (var actorNode in nodes)
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var toResolve = new Queue<string>(inheritsMap.Keys.Where(k => string.Equals(k, actor, StringComparison.InvariantCultureIgnoreCase)));
|
var toResolve = new Queue<string>(inheritsMap.Keys.Where(k => string.Equals(k, actor, StringComparison.InvariantCultureIgnoreCase)));
|
||||||
while (toResolve.TryDequeue(out var key))
|
while (toResolve.TryDequeue(out var key))
|
||||||
{
|
{
|
||||||
// Missing keys are a fatal merge error, so will have already been reported by other lint checks
|
// Missing keys are a fatal merge error, so will have already been reported by other lint checks.
|
||||||
if (!inheritsMap.TryGetValue(key, out var inherits))
|
if (!inheritsMap.TryGetValue(key, out var inherits))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
var providedPrereqs = rules.Actors.SelectMany(a => a.Value.TraitInfos<ITechTreePrerequisiteInfo>().SelectMany(p => p.Prerequisites(a.Value)));
|
var providedPrereqs = rules.Actors.SelectMany(a => a.Value.TraitInfos<ITechTreePrerequisiteInfo>().SelectMany(p => p.Prerequisites(a.Value)));
|
||||||
|
|
||||||
// TODO: this check is case insensitive while the real check in-game is not
|
// TODO: this check is case insensitive while the real check in-game is not.
|
||||||
foreach (var actorInfo in rules.Actors)
|
foreach (var actorInfo in rules.Actors)
|
||||||
{
|
{
|
||||||
// Catch TypeDictionary errors
|
// Catch TypeDictionary errors.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var bi = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
var bi = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
||||||
{
|
{
|
||||||
// Use an intermediate list to cover the unlikely case where both keys and values are lintable
|
// Use an intermediate list to cover the unlikely case where both keys and values are lintable.
|
||||||
var dictionaryValues = new List<string>();
|
var dictionaryValues = new List<string>();
|
||||||
if (dictionaryReference.HasFlag(LintDictionaryReference.Keys) && type.GenericTypeArguments[0] == typeof(string))
|
if (dictionaryReference.HasFlag(LintDictionaryReference.Keys) && type.GenericTypeArguments[0] == typeof(string))
|
||||||
dictionaryValues.AddRange((IEnumerable<string>)((IDictionary)fieldInfo.GetValue(ruleInfo)).Keys);
|
dictionaryValues.AddRange((IEnumerable<string>)((IDictionary)fieldInfo.GetValue(ruleInfo)).Keys);
|
||||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
||||||
{
|
{
|
||||||
// Use an intermediate list to cover the unlikely case where both keys and values are lintable
|
// Use an intermediate list to cover the unlikely case where both keys and values are lintable.
|
||||||
var dictionaryValues = new List<string>();
|
var dictionaryValues = new List<string>();
|
||||||
if (dictionaryReference.HasFlag(LintDictionaryReference.Keys) && type.GenericTypeArguments[0] == typeof(string))
|
if (dictionaryReference.HasFlag(LintDictionaryReference.Keys) && type.GenericTypeArguments[0] == typeof(string))
|
||||||
dictionaryValues.AddRange((IEnumerable<string>)((IDictionary)propertyInfo.GetValue(ruleInfo)).Keys);
|
dictionaryValues.AddRange((IEnumerable<string>)((IDictionary)propertyInfo.GetValue(ruleInfo)).Keys);
|
||||||
|
|||||||
Reference in New Issue
Block a user