Skip to content

Commit

Permalink
final warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EliphasNUIT committed Nov 19, 2024
1 parent 4694621 commit 36ea2a8
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tab_width = 4
end_of_line = crlf
dotnet_style_prefer_collection_expression = true:suggestion
dotnet_diagnostic.CA1416.severity = suggestion
dotnet_diagnostic.CA2201.severity = suggestion
###############################
# C# Coding Conventions #
###############################
Expand Down Expand Up @@ -254,6 +255,7 @@ csharp_style_expression_bodied_local_functions = false:silent
dotnet_diagnostic.IDE0002.severity = warning
dotnet_diagnostic.IDE0305.severity = silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion

[*.vb]
# Modifier preferences
Expand Down
2 changes: 2 additions & 0 deletions GW2EIDPSReport/DPSReportJsons/DPSReportUploadObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace GW2EIDPSReport.DPSReportJsons;

#pragma warning disable CS0649 // field never assigned to
public class DPSReportUploadObject
{

Expand Down Expand Up @@ -58,3 +59,4 @@ public Dictionary<string, DPSReportUploadPlayerObject> Players

public string TempApiId;
}
#pragma warning restore CS0649 // field never assigned to
36 changes: 23 additions & 13 deletions GW2EIEvtcParser/EIData/Buffs/BuffDistribution.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GW2EIEvtcParser.ParsedData;
using System.Diagnostics.CodeAnalysis;
using GW2EIEvtcParser.ParsedData;

namespace GW2EIEvtcParser.EIData;

Expand Down Expand Up @@ -82,49 +83,58 @@ public bool HasSrc(long buffID, AgentItem src)
public List<SingleActor> GetSrcs(long buffID, ParsedEvtcLog log)
{
var actors = new List<SingleActor>();
if (!_distribution.ContainsKey(buffID))
if (_distribution.TryGetValue(buffID, out var buffsByAgent))
{
return actors;
actors.AddRange(buffsByAgent.Keys.Select(x => log.FindActor(x)));
}
foreach (AgentItem agent in _distribution[buffID].Keys)
return actors;
}

private bool TryGetBuffDistribution(long buffID, AgentItem src, [NotNullWhen(returnValue: true)] out BuffDistributionItem? distrib)
{
distrib = null;
if (_distribution.TryGetValue(buffID, out var buffsByAgent))
{
actors.Add(log.FindActor(agent));
if (buffsByAgent.TryGetValue(src, out distrib))
{
return true;
}
}
return actors;
return false;
}

public long GetUptime(long buffID)
{
return !_distribution.ContainsKey(buffID) ? 0 : _distribution[buffID].Sum(x => x.Value.Value);
return !_distribution.TryGetValue(buffID, out var buffsByAgent) ? 0 : buffsByAgent.Sum(x => x.Value.Value);
}

public long GetGeneration(long buffID, AgentItem src)
{
return !_distribution.ContainsKey(buffID) || !_distribution[buffID].ContainsKey(src) ? 0 : _distribution[buffID][src].Value;
return !TryGetBuffDistribution(buffID, src, out var distrib) ? 0 : distrib.Value;
}

public long GetOverstack(long buffID, AgentItem src)
{
return !_distribution.ContainsKey(buffID) || !_distribution[buffID].ContainsKey(src) ? 0 : _distribution[buffID][src].Overstack;
return !TryGetBuffDistribution(buffID, src, out var distrib) ? 0 : distrib.Overstack;
}

public long GetWaste(long buffID, AgentItem src)
{
return !_distribution.ContainsKey(buffID) || !_distribution[buffID].ContainsKey(src) ? 0 : _distribution[buffID][src].Waste;
return !TryGetBuffDistribution(buffID, src, out var distrib) ? 0 : distrib.Waste;
}

public long GetUnknownExtension(long buffID, AgentItem src)
{
return !_distribution.ContainsKey(buffID) || !_distribution[buffID].ContainsKey(src) ? 0 : _distribution[buffID][src].UnknownExtension;
return !TryGetBuffDistribution(buffID, src, out var distrib) ? 0 : distrib.UnknownExtension;
}

public long GetExtension(long buffID, AgentItem src)
{
return !_distribution.ContainsKey(buffID) || !_distribution[buffID].ContainsKey(src) ? 0 : _distribution[buffID][src].Extension;
return !TryGetBuffDistribution(buffID, src, out var distrib) ? 0 : distrib.Extension;
}

public long GetExtended(long buffID, AgentItem src)
{
return !_distribution.ContainsKey(buffID) || !_distribution[buffID].ContainsKey(src) ? 0 : _distribution[buffID][src].Extended;
return !TryGetBuffDistribution(buffID, src, out var distrib) ? 0 : distrib.Extended;
}
}
7 changes: 5 additions & 2 deletions GW2EIEvtcParser/EIData/Buffs/BuffsGraphModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ internal void MergePresenceInto(IReadOnlyList<Segment> from)
{
segmentsToFill.AddAfter(node, new Segment(start, end, curVal + presence));
node = node.Next;
segmentsToFill.AddAfter(node, new Segment(end, curEnd, curVal));
node = node.Next;
if (node != null)
{
segmentsToFill.AddAfter(node, new Segment(end, curEnd, curVal));
node = node.Next;
}
break;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ private static long TranslateWeaverAttunement(List<BuffApplyEvent> buffApplies)
{
return c.BuffID;
}
if (_majorsTranslation.ContainsKey(c.BuffID))
if (_majorsTranslation.TryGetValue(c.BuffID, out var potentialMajors))
{
major = _majorsTranslation[c.BuffID];
major = potentialMajors;
}
else if (_minorsTranslation.ContainsKey(c.BuffID))
else if (_minorsTranslation.TryGetValue(c.BuffID, out var potentialMinors))
{
minor = _minorsTranslation[c.BuffID];
minor = potentialMinors;
}
}
if (major == null || minor == null)
Expand Down
2 changes: 1 addition & 1 deletion GW2EIEvtcParser/EIData/Statistics/StatisticsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal StatisticsHelper(CombatData combatData, IReadOnlyList<Player> players,
}

// All class specific boons
var remainingBuffsByIds = buffs.BuffsByClassification[BuffClassification.Other].GroupBy(x => x.ID).ToDictionary(x => x.Key, x => x.FirstOrDefault());
var remainingBuffsByIds = buffs.BuffsByClassification[BuffClassification.Other].GroupBy(x => x.ID).ToDictionary(x => x.Key, x => x.FirstOrDefault()!);
foreach (Player player in players)
{
_presentRemainingBuffsPerPlayer[player] = [];
Expand Down
6 changes: 6 additions & 0 deletions GW2EIEvtcParser/ParserHelpers/ArrayPoolReturner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace GW2EIEvtcParser.ParserHelpers;


#pragma warning disable CA2002 // weak identity lock

internal struct ArrayPoolReturner<T> : IDisposable
{
public readonly ArrayPool<T> Pool;
Expand Down Expand Up @@ -339,8 +342,10 @@ private Gen2GcCallback(Func<object, bool> callback, object targetObj)
/// </summary>
public static void Register(Func<bool> callback)
{
#pragma warning disable CA1806 // unused new instance
// Create a unreachable object that remembers the callback function and target object.
new Gen2GcCallback(callback);
#pragma warning restore CA1806 // unused new instance
}

/// <summary>
Expand Down Expand Up @@ -691,3 +696,4 @@ private static bool TryGetInt32EnvironmentVariable(string variable, out int resu
return false;
}
}
#pragma warning restore CA2002 // weak identity lock
3 changes: 3 additions & 0 deletions GW2EIEvtcParser/ParserHelpers/ParserIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace GW2EIEvtcParser.ParserHelpers;

#pragma warning disable CA1823 // Unused field
internal static class ParserIcons
{
/// <summary>
Expand Down Expand Up @@ -1563,3 +1564,5 @@ internal static class ParserIcons
{ MarkerGUIDs.WhiteCatmanderTag, WhiteCatmanderTagOverhead },
};
}

#pragma warning restore CA1823 // Unused field
32 changes: 31 additions & 1 deletion GW2EIEvtcParser/StableSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,37 @@

namespace GW2EIEvtcParser;

// https://github.com/scandum/fluxsort
// https://github.com/scandum/fluxsort/blob/main/LICENSE
// UNLICENSE
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>
*/


#pragma warning disable CA1000 // static on generic type

public static unsafe class StableSort<T>
{
Expand Down Expand Up @@ -1657,3 +1686,4 @@ static void fluxsort_swap(Span<T> array, Span<T> swap, Func<T, T, int> cmp)
}
}
}
#pragma warning restore CA1000 // static on generic type
2 changes: 2 additions & 0 deletions GW2EIEvtcParser/Tracing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Tracing;

#pragma warning disable IDE0060 // Remove unused parameter
#pragma warning disable CA1822 // static members

public static class Trace
{
Expand Down Expand Up @@ -145,3 +146,4 @@ void IDisposable.Dispose() { }
}

#pragma warning restore IDE0060 // Remove unused parameter
#pragma warning restore CA1822 // static members

0 comments on commit 36ea2a8

Please sign in to comment.