Code cleanup/add suppressions

pull/7/head
Liza 2024-07-16 10:54:47 +02:00
parent 985fb7f4c1
commit e239edb22c
Signed by: liza
GPG Key ID: 7199F8D727D55F67
6 changed files with 20 additions and 17 deletions

View File

@ -1,8 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Questionable.Model.V1; using Questionable.Model.V1;
namespace Questionable.QuestPaths; namespace Questionable.QuestPaths;
[SuppressMessage("ReSharper", "PartialTypeWithSinglePart", Justification = "Required for RELEASE")]
public static partial class AssemblyQuestLoader public static partial class AssemblyQuestLoader
{ {
public static IReadOnlyDictionary<ushort, QuestRoot> GetQuests() => public static IReadOnlyDictionary<ushort, QuestRoot> GetQuests() =>

View File

@ -8,12 +8,12 @@ public sealed class ExcelRefConverter : JsonConverter<ExcelRef>
{ {
public override ExcelRef? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override ExcelRef? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
if (reader.TokenType == JsonTokenType.String) return reader.TokenType switch
return new ExcelRef(reader.GetString()!); {
else if (reader.TokenType == JsonTokenType.Number) JsonTokenType.String => ExcelRef.FromKey(reader.GetString()!),
return new ExcelRef(reader.GetUInt32()); JsonTokenType.Number => ExcelRef.FromRowId(reader.GetUInt32()),
else _ => null
return null; };
} }
public override void Write(Utf8JsonWriter writer, ExcelRef? value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, ExcelRef? value, JsonSerializerOptions options)

View File

@ -21,20 +21,16 @@ public class ExcelRef
Type = EType.RowId; Type = EType.RowId;
} }
/// <summary> private ExcelRef(string? stringValue, uint? rowIdValue, EType type)
/// Only used internally (not serialized) with specific values that have been read from the sheets already.
/// </summary>
private ExcelRef(string value, bool v)
{ {
if (!v) _stringValue = stringValue;
throw new ArgumentException(nameof(v)); _rowIdValue = rowIdValue;
Type = type;
_stringValue = value;
_rowIdValue = null;
Type = EType.RawString;
} }
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; } public EType Type { get; }

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects;
@ -104,6 +105,7 @@ internal sealed class CombatController
return _condition[ConditionFlag.InCombat]; return _condition[ConditionFlag.InCombat];
} }
[SuppressMessage("ReSharper", "RedundantJumpStatement")]
private IGameObject? FindNextTarget() private IGameObject? FindNextTarget()
{ {
if (_currentFight == null) if (_currentFight == null)

View File

@ -146,6 +146,7 @@ internal sealed class GameUiController : IDisposable
SelectIconStringPostSetup(addonSelectIconString, false); SelectIconStringPostSetup(addonSelectIconString, false);
} }
[SuppressMessage("ReSharper", "RedundantJumpStatement")]
private unsafe void SelectIconStringPostSetup(AddonSelectIconString* addonSelectIconString, bool checkAllSteps) private unsafe void SelectIconStringPostSetup(AddonSelectIconString* addonSelectIconString, bool checkAllSteps)
{ {
string? actualPrompt = addonSelectIconString->AtkUnitBase.AtkValues[3].ReadAtkString(); string? actualPrompt = addonSelectIconString->AtkUnitBase.AtkValues[3].ReadAtkString();

View File

@ -274,6 +274,7 @@ internal sealed class QuestSelectionWindow : LWindow
{ {
var qInfo = _questData.GetQuestInfo(q); var qInfo = _questData.GetQuestInfo(q);
var (iconColor, icon, _) = GetQuestStyle(q); var (iconColor, icon, _) = GetQuestStyle(q);
// ReSharper disable once UnusedVariable
using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push()) using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
{ {
if (_questRegistry.IsKnownQuest(qInfo.QuestId)) if (_questRegistry.IsKnownQuest(qInfo.QuestId))
@ -305,6 +306,7 @@ internal sealed class QuestSelectionWindow : LWindow
{ {
var qInfo = _questData.GetQuestInfo(q); var qInfo = _questData.GetQuestInfo(q);
var (iconColor, icon, _) = GetQuestStyle(q); var (iconColor, icon, _) = GetQuestStyle(q);
// ReSharper disable once UnusedVariable
using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push()) using (var font = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
{ {
if (_questRegistry.IsKnownQuest(qInfo.QuestId)) if (_questRegistry.IsKnownQuest(qInfo.QuestId))