Code cleanup/add suppressions
authorLiza Carvelli <liza@carvel.li>
Tue, 16 Jul 2024 08:54:47 +0000 (10:54 +0200)
committerLiza Carvelli <liza@carvel.li>
Tue, 16 Jul 2024 08:54:47 +0000 (10:54 +0200)
QuestPaths/AssemblyQuestLoader.cs
Questionable.Model/V1/Converter/ExcelRefConverter.cs
Questionable.Model/V1/ExcelRef.cs
Questionable/Controller/CombatController.cs
Questionable/Controller/GameUiController.cs
Questionable/Windows/QuestSelectionWindow.cs

index b0b8efc01e679ceefe1abff2ae3412d0dc71a873..3c8b7b714c155bb5a3bf2940ac4bed9d32eecc63 100644 (file)
@@ -1,8 +1,10 @@
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using Questionable.Model.V1;
 
 namespace Questionable.QuestPaths;
 
+[SuppressMessage("ReSharper", "PartialTypeWithSinglePart", Justification = "Required for RELEASE")]
 public static partial class AssemblyQuestLoader
 {
     public static IReadOnlyDictionary<ushort, QuestRoot> GetQuests() =>
index 0c48e5bbc9d2456ba428d75f6e0b4fd764660313..06ba3ff169be1a113c952b7c8ac8db4f03be6af0 100644 (file)
@@ -8,12 +8,12 @@ public sealed class ExcelRefConverter : JsonConverter<ExcelRef>
 {
     public override ExcelRef? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
     {
-        if (reader.TokenType == JsonTokenType.String)
-            return new ExcelRef(reader.GetString()!);
-        else if (reader.TokenType == JsonTokenType.Number)
-            return new ExcelRef(reader.GetUInt32());
-        else
-            return null;
+        return reader.TokenType switch
+        {
+            JsonTokenType.String => ExcelRef.FromKey(reader.GetString()!),
+            JsonTokenType.Number => ExcelRef.FromRowId(reader.GetUInt32()),
+            _ => null
+        };
     }
 
     public override void Write(Utf8JsonWriter writer, ExcelRef? value, JsonSerializerOptions options)
index 979a1897a85329f79c92c72385b9eadc865fb8f3..295dd5ba686e8a6837f5bc0ff8230c36f61a1f90 100644 (file)
@@ -21,20 +21,16 @@ public class ExcelRef
         Type = EType.RowId;
     }
 
-    /// <summary>
-    /// Only used internally (not serialized) with specific values that have been read from the sheets already.
-    /// </summary>
-    private ExcelRef(string value, bool v)
+    private ExcelRef(string? stringValue, uint? rowIdValue, EType type)
     {
-        if (!v)
-            throw new ArgumentException(nameof(v));
-
-        _stringValue = value;
-        _rowIdValue = null;
-        Type = EType.RawString;
+        _stringValue = stringValue;
+        _rowIdValue = rowIdValue;
+        Type = type;
     }
 
-    public static ExcelRef FromSheetValue(string value) => new(value, true);
+    public static ExcelRef FromKey(string value) => new(value, null, EType.Key);
+    public static ExcelRef FromRowId(uint rowId) => new(null, rowId, EType.RowId);
+    public static ExcelRef FromSheetValue(string value) => new(value, null, EType.RawString);
 
     public EType Type { get; }
 
index 51f48385082056bd12e31e63b9b395933223cc3c..aada0a1abf5fc5b025f22361a9c9d0c6516bc0c6 100644 (file)
@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using Dalamud.Game.ClientState.Conditions;
 using Dalamud.Game.ClientState.Objects;
@@ -104,6 +105,7 @@ internal sealed class CombatController
         return _condition[ConditionFlag.InCombat];
     }
 
+    [SuppressMessage("ReSharper", "RedundantJumpStatement")]
     private IGameObject? FindNextTarget()
     {
         if (_currentFight == null)
index dba30ec07bd102d88ed6fa04a9b8ed8f2974b206..efba25f06e322ace8b4853f68e09af50b238bc24 100644 (file)
@@ -146,6 +146,7 @@ internal sealed class GameUiController : IDisposable
         SelectIconStringPostSetup(addonSelectIconString, false);
     }
 
+    [SuppressMessage("ReSharper", "RedundantJumpStatement")]
     private unsafe void SelectIconStringPostSetup(AddonSelectIconString* addonSelectIconString, bool checkAllSteps)
     {
         string? actualPrompt = addonSelectIconString->AtkUnitBase.AtkValues[3].ReadAtkString();
index 55d81bb50d03b49dd471cacc6ed05a0728ac6b86..164f03b62af436cfbd41f2ce9fd041a521df7771 100644 (file)
@@ -274,6 +274,7 @@ internal sealed class QuestSelectionWindow : LWindow
             {
                 var qInfo = _questData.GetQuestInfo(q);
                 var (iconColor, icon, _) = GetQuestStyle(q);
+                // ReSharper disable once UnusedVariable
                 using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
                 {
                     if (_questRegistry.IsKnownQuest(qInfo.QuestId))
@@ -305,6 +306,7 @@ internal sealed class QuestSelectionWindow : LWindow
             {
                 var qInfo = _questData.GetQuestInfo(q);
                 var (iconColor, icon, _) = GetQuestStyle(q);
+                // ReSharper disable once UnusedVariable
                 using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
                 {
                     if (_questRegistry.IsKnownQuest(qInfo.QuestId))