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 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;
|
||||
CheckLaunchAngles(weaponInfo.Key, minAngle, testMaxAngle, maxAngle, emitError);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
var minAngle = bullet.LaunchAngle[0].Angle;
|
||||
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;
|
||||
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)
|
||||
{
|
||||
// Build the list of valid hotkey names
|
||||
// Build the list of valid hotkey names.
|
||||
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>()
|
||||
.SelectMany(w => Utility.GetFields(w)
|
||||
.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];
|
||||
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");
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
// Catch TypeDictionary errors
|
||||
// Catch TypeDictionary errors.
|
||||
try
|
||||
{
|
||||
var count = actorInfo.Value.TraitInfos<IDefaultVisibilityInfo>().Count();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
// Catch TypeDictionary errors
|
||||
// Catch TypeDictionary errors.
|
||||
try
|
||||
{
|
||||
var health = actorInfo.Value.TraitInfoOrDefault<IHealthInfo>();
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
.Select(p => p.Name)
|
||||
.ToHashSet();
|
||||
|
||||
// Check for actors that require specific owners
|
||||
// Check for actors that require specific owners.
|
||||
var actorsWithRequiredOwner = map.Rules.Actors
|
||||
.Where(a => a.Value.HasTraitInfo<RequiresSpecificOwnersInfo>())
|
||||
.ToDictionary(a => a.Key, a => a.Value.TraitInfo<RequiresSpecificOwnersInfo>());
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
tilesetPalettes.Add(tilesetPalette);
|
||||
|
||||
// Only add the basic palette name once
|
||||
// Only add the basic palette name once.
|
||||
if (!palettes.Contains(value))
|
||||
palettes.Add(value);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
// Catch TypeDictionary errors
|
||||
// Catch TypeDictionary errors.
|
||||
try
|
||||
{
|
||||
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();
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
// Catch TypeDictionary errors
|
||||
// Catch TypeDictionary errors.
|
||||
try
|
||||
{
|
||||
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>();
|
||||
if (renderInfo != null)
|
||||
{
|
||||
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)
|
||||
images.Add(renderInfo.GetImage(actorInfo.Value, faction).ToLowerInvariant());
|
||||
}
|
||||
|
||||
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
|
||||
{
|
||||
// Remove the "Info" suffix
|
||||
// Remove the "Info" suffix.
|
||||
var traitName = traitInfo.GetType().Name;
|
||||
traitName = traitName.Remove(traitName.Length - 4);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
if (sequenceReference == null)
|
||||
continue;
|
||||
|
||||
// Some sequences may specify their own Image override
|
||||
// Some sequences may specify their own Image override.
|
||||
IEnumerable<string> sequenceImages = images;
|
||||
if (!string.IsNullOrEmpty(sequenceReference.ImageReference))
|
||||
{
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
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)))
|
||||
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)
|
||||
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);
|
||||
if (string.IsNullOrEmpty(image))
|
||||
{
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
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)))
|
||||
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)
|
||||
{
|
||||
// Catch TypeDictionary errors
|
||||
// Catch TypeDictionary errors.
|
||||
try
|
||||
{
|
||||
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))
|
||||
{
|
||||
// Remove the "Info" suffix
|
||||
// Remove the "Info" suffix.
|
||||
var traitName = traitInfo.GetType().Name;
|
||||
traitName = traitName.Remove(traitName.Length - 4);
|
||||
var locations = traitLocation.SystemActors.ToString().Replace(", ", " or ");
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
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))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
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.Value.Nodes.Count > 0)
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
var traitName = NormalizeName(t.Key);
|
||||
|
||||
// Inherits can never define children
|
||||
// Inherits can never define children.
|
||||
if (traitName == "Inherits")
|
||||
{
|
||||
if (t.Value.Nodes.Count > 0)
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
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>>();
|
||||
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)));
|
||||
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))
|
||||
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)));
|
||||
|
||||
// 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)
|
||||
{
|
||||
// Catch TypeDictionary errors
|
||||
// Catch TypeDictionary errors.
|
||||
try
|
||||
{
|
||||
var bi = actorInfo.Value.TraitInfoOrDefault<BuildableInfo>();
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
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>();
|
||||
if (dictionaryReference.HasFlag(LintDictionaryReference.Keys) && type.GenericTypeArguments[0] == typeof(string))
|
||||
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<,>))
|
||||
{
|
||||
// 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>();
|
||||
if (dictionaryReference.HasFlag(LintDictionaryReference.Keys) && type.GenericTypeArguments[0] == typeof(string))
|
||||
dictionaryValues.AddRange((IEnumerable<string>)((IDictionary)propertyInfo.GetValue(ruleInfo)).Keys);
|
||||
|
||||
Reference in New Issue
Block a user