Skip to content

Commit

Permalink
bump AnalysisModeUsage to Recommended
Browse files Browse the repository at this point in the history
fixes CA2211, CA2215, CA2241, CA2251

silence CA1816 because it's unnecessary

reduce severity of CA2201 because I like the concept but don't wanna fix them all
  • Loading branch information
Morilli committed Jul 23, 2023
1 parent 1a68961 commit 8599fba
Show file tree
Hide file tree
Showing 30 changed files with 86 additions and 78 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ dotnet_code_quality.CA1826.exclude_ordefault_methods = true
dotnet_diagnostic.CA1805.severity = silent
dotnet_diagnostic.CA1822.severity = silent
dotnet_diagnostic.CA1838.severity = suggestion

# Usage rules
dotnet_diagnostic.CA1816.severity = none
dotnet_diagnostic.CA2201.severity = suggestion
1 change: 1 addition & 0 deletions Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AnalysisModeMaintainability>Recommended</AnalysisModeMaintainability>
<AnalysisModeReliability>Recommended</AnalysisModeReliability>
<AnalysisModePerformance>Recommended</AnalysisModePerformance>
<AnalysisModeUsage>Recommended</AnalysisModeUsage>
<CodeAnalysisRuleSet>$(MSBuildProjectDirectory)/../../Common.ruleset</CodeAnalysisRuleSet>
<ContinuousIntegrationBuild Condition=" '$(GITLAB_CI)' != '' Or '$(APPVEYOR)' != '' ">true</ContinuousIntegrationBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
Expand Down
4 changes: 2 additions & 2 deletions src/BizHawk.Bizware.BizwareGL/TexAtlas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private class TryFitParam
public readonly List<RectangleBinPack.Node> nodes = new List<RectangleBinPack.Node>();
}

public static int MaxSizeBits = 16;
private const int MaxSizeBits = 16;

/// <summary>
/// packs the supplied RectItems into an atlas. Modifies the RectItems with x/y values of location in new atlas.
Expand Down Expand Up @@ -278,4 +278,4 @@ private Node Insert(Node node, int width, int height)
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/BizHawk.Client.Common/RecentFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public bool Remove(string newFile)
{
if (!Frozen)
{
return recentlist.RemoveAll(recent => string.Compare(newFile, recent, StringComparison.OrdinalIgnoreCase) == 0) != 0; // none removed => return false
return recentlist.RemoveAll(recent => string.Equals(newFile, recent, StringComparison.OrdinalIgnoreCase)) != 0; // none removed => return false
}

return false;
Expand Down
16 changes: 8 additions & 8 deletions src/BizHawk.Client.Common/config/MessagePosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public static bool IsLeft(this MessagePosition.AnchorType type)

public static class DefaultMessagePositions
{
public static MessagePosition Fps = new MessagePosition { X = 0, Y = 0 };
public static MessagePosition FrameCounter = new MessagePosition { X = 0, Y = 14 };
public static MessagePosition LagCounter = new MessagePosition { X = 0, Y = 42 };
public static MessagePosition InputDisplay = new MessagePosition { X = 0, Y = 28 };
public static MessagePosition ReRecordCounter = new MessagePosition { X = 0, Y = 56 };
public static MessagePosition Messages = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.BottomLeft };
public static MessagePosition Autohold = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.TopRight };
public static MessagePosition RamWatches = new MessagePosition { X = 0, Y = 70 };
public static readonly MessagePosition Fps = new MessagePosition { X = 0, Y = 0 };
public static readonly MessagePosition FrameCounter = new MessagePosition { X = 0, Y = 14 };
public static readonly MessagePosition LagCounter = new MessagePosition { X = 0, Y = 42 };
public static readonly MessagePosition InputDisplay = new MessagePosition { X = 0, Y = 28 };
public static readonly MessagePosition ReRecordCounter = new MessagePosition { X = 0, Y = 56 };
public static readonly MessagePosition Messages = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.BottomLeft };
public static readonly MessagePosition Autohold = new MessagePosition { X = 0, Y = 0, Anchor = MessagePosition.AnchorType.TopRight };
public static readonly MessagePosition RamWatches = new MessagePosition { X = 0, Y = 70 };

public const int
MessagesColor = -1,
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Client.Common/config/PathEntryCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void ResolveWithDefaults()
[JsonIgnore]
internal string TempFilesFragment => this[GLOBAL, "Temp Files"].Path;

public static Lazy<IReadOnlyList<PathEntry>> Defaults = new(() => new[]
public static readonly Lazy<IReadOnlyList<PathEntry>> Defaults = new(() => new[]
{
new[] {
BaseEntryFor(GLOBAL, "."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public int Compare(Watch x, Watch y)
return 0;
}

if (string.Compare(x.Notes, y.Notes, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Equals(x.Notes, y.Notes, StringComparison.OrdinalIgnoreCase))
{
if (x.Address.Equals(y.Address))
{
Expand Down
2 changes: 0 additions & 2 deletions src/BizHawk.Client.DiscoHawk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ private static void SubMain(string[] args)
OSTC.LinkedLibManager.FreeByPtr(lib);
}

FFmpegService.FFmpegPath = Path.Combine(PathUtils.DataDirectoryPath, "dll", OSTC.IsUnixHost ? "ffmpeg" : "ffmpeg.exe");

if (args.Length == 0)
{
using var dialog = new MainDiscoForm();
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Client.EmuHawk/Input/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void ControlInputFocus(Control c, ClientInputFocus types, bool wants)

private readonly HashSet<Control> _wantingMouseFocus = new HashSet<Control>();

public static Input Instance;
public static Input Instance { get; set; }

private readonly Thread _updateThread;

Expand Down
2 changes: 0 additions & 2 deletions src/BizHawk.Client.EmuHawk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ private static int SubMain(string[] args)
if (initialConfig.SaveSlot is 0) initialConfig.SaveSlot = 10; //TODO remove after a while
// initialConfig should really be globalConfig as it's mutable

FFmpegService.FFmpegPath = Path.Combine(PathUtils.DataDirectoryPath, "dll", OSTC.IsUnixHost ? "ffmpeg" : "ffmpeg.exe");

StringLogUtil.DefaultToDisk = initialConfig.Movies.MoviesOnDisk;

var glInitCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Client.EmuHawk/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class UpdateChecker
private static readonly string _latestVersionInfoURL = "https://api.github.com/repos/TASVideos/BizHawk/releases/latest";
private static readonly TimeSpan _minimumCheckDuration = TimeSpan.FromHours(8);

public static Config GlobalConfig;
public static Config GlobalConfig { get; set; }

private static bool AutoCheckEnabled
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk
/// </remarks>
public readonly struct TAStudioPalette
{
public static TAStudioPalette Default = new(
public static readonly TAStudioPalette Default = new(
// currentFrame_FrameCol: Color.FromArgb(0xCF, 0xED, 0xFC),
currentFrame_InputLog: Color.FromArgb(0xB5, 0xE7, 0xF7),
greenZone_FrameCol: Color.FromArgb(0xDD, 0xFF, 0xDD),
Expand Down
5 changes: 3 additions & 2 deletions src/BizHawk.Common/FFmpegService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text.RegularExpressions;
using System.IO;
using System.Threading.Tasks;
using BizHawk.Common.PathExtensions;

namespace BizHawk.Common
{
Expand All @@ -18,7 +19,7 @@ public static class FFmpegService

private const string VERSION = "ffmpeg version 4.4.1";

public static string FFmpegPath = string.Empty; // always updated in DiscoHawk.Program/EmuHawk.Program
public static string FFmpegPath => Path.Combine(PathUtils.DataDirectoryPath, "dll", OSTailoredCode.IsUnixHost ? "ffmpeg" : "ffmpeg.exe");

public static readonly string Url = OSTailoredCode.IsUnixHost ? BIN_HOST_URI_LINUX_X64 : BIN_HOST_URI_WIN_X64;

Expand Down Expand Up @@ -155,4 +156,4 @@ public static byte[] DecodeAudio(string path)
}
}

}
}
2 changes: 1 addition & 1 deletion src/BizHawk.Common/HawkFile/HawkFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void Unbind()
}

/// <summary>Set this with an instance which can construct archive handlers as necessary for archive handling.</summary>
public static IFileDearchivalMethod<IHawkArchiveFile>? DearchivalMethod;
public static IFileDearchivalMethod<IHawkArchiveFile>? DearchivalMethod { get; set; }

[return: HawkFilePath]
private static string MakeCanonicalName(string root, string? member) => member == null ? root : $"{root}|{member}";
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Common/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void DisableDomain(string domain)
}

// -------------- Logging Action Configuration --------------
public static Action<string> LogAction = DefaultLogger;
public static readonly Action<string> LogAction = DefaultLogger;

// NOTEs are only logged if the domain is enabled.
// ERRORs are logged regardless.
Expand Down
10 changes: 5 additions & 5 deletions src/BizHawk.Emulation.Common/Sound/Waves.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace BizHawk.Emulation.Common
{
public static class Waves
{
public static short[] SquareWave;
public static short[] ImperfectSquareWave;
public static short[] NoiseWave;
public static short[] PeriodicWave16;
public static short[] SquareWave { get; private set; }
public static short[] ImperfectSquareWave { get; private set; }
public static short[] NoiseWave { get; private set; }
public static short[] PeriodicWave16 { get; private set; }

public static void InitWaves()
{
Expand Down Expand Up @@ -56,4 +56,4 @@ public static void InitWaves()
#endif
}
}
}
}
4 changes: 4 additions & 0 deletions src/BizHawk.Emulation.Common/zstd/Zstd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ protected override void Dispose(bool disposing)
_ctx.InUse = false;
_disposed = true;
}

base.Dispose(disposing);
}

public override bool CanRead
Expand Down Expand Up @@ -286,6 +288,8 @@ protected override void Dispose(bool disposing)
_ctx.InUse = false;
_disposed = true;
}

base.Dispose(disposing);
}

public override bool CanRead
Expand Down
32 changes: 16 additions & 16 deletions src/BizHawk.Emulation.Cores/CPUs/LR35902/Registers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ public partial class LR35902
{
// registers

public static ushort PCl = 0;
public static ushort PCh = 1;
public static ushort SPl = 2;
public static ushort SPh = 3;
public static ushort A = 4;
public static ushort F = 5;
public static ushort B = 6;
public static ushort C = 7;
public static ushort D = 8;
public static ushort E = 9;
public static ushort H = 10;
public static ushort L = 11;
public static ushort W = 12;
public static ushort Z = 13;
public static ushort Aim = 14; // use this indicator for RLCA etc., since the Z flag is reset on those
public const ushort PCl = 0;
public const ushort PCh = 1;
public const ushort SPl = 2;
public const ushort SPh = 3;
public const ushort A = 4;
public const ushort F = 5;
public const ushort B = 6;
public const ushort C = 7;
public const ushort D = 8;
public const ushort E = 9;
public const ushort H = 10;
public const ushort L = 11;
public const ushort W = 12;
public const ushort Z = 13;
public const ushort Aim = 14; // use this indicator for RLCA etc., since the Z flag is reset on those

public ushort[] Regs = new ushort[14];

Expand Down Expand Up @@ -151,4 +151,4 @@ public void SetCpuRegister(string register, int value)
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public string Disassemble(uint addr, Func<long, byte> peek, ref byte P, out int
break;
// Block Move
case 0x44: case 0x54:
pbuf = string.Format("${0:X2},${0:X2}", peek(addr + 1), peek(addr + 2));
pbuf = $"${peek(addr + 1):X2},${peek(addr + 2):X2}";
//sprintf(pbuf, "$%02X,$%02X", mem[1], mem[2]);
offset = 3;
break;
Expand Down Expand Up @@ -494,4 +494,4 @@ public string Disassemble(uint addr, Func<long, byte> peek, ref byte P, out int
return sb.ToString();
}
}
}
}
8 changes: 4 additions & 4 deletions src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ public void HardReset()

private IntPtr MSX_Pntr { get; set; } = IntPtr.Zero;
private byte[] MSX_core = new byte[0x28000];
public static byte[] Bios = null;
public static byte[] Basic;
private static byte[] Bios = null;
private static byte[] Basic;

// Constants
private const int BankSize = 16384;

// ROM
public static byte[] RomData;
public static byte[] RomData2;
private static byte[] RomData;
private static byte[] RomData2;

// Machine resources
private IController _controller = NullController.Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public void apply_filter()

}

public static Dictionary<string, string> ValidFilterTypes = new Dictionary<string, string>
public static readonly Dictionary<string, string> ValidFilterTypes = new Dictionary<string, string>
{
{ "None", "None"},
{ "NTSC", "NTSC"},
Expand Down
12 changes: 6 additions & 6 deletions src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ private struct GFX_Object
public int DMA_phase = 0;
public int DMA_phase_counter;

public static int DMA_START_UP = 0;
public static int DMA_HEADER = 1;
public static int DMA_GRAPHICS = 2;
public static int DMA_CHAR_MAP = 3;
public static int DMA_SHUTDOWN_OTHER = 4;
public static int DMA_SHUTDOWN_LAST = 5;
public const int DMA_START_UP = 0;
public const int DMA_HEADER = 1;
public const int DMA_GRAPHICS = 2;
public const int DMA_CHAR_MAP = 3;
public const int DMA_SHUTDOWN_OTHER = 4;
public const int DMA_SHUTDOWN_LAST = 5;

public int header_read_time = 8; // default for 4 byte headers (10 for 5 bytes ones)
public int graphics_read_time = 3; // depends on content of graphics header
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PPU
public int skip;
public uint bright_int_1, bright_int_2, bright_int_3;

public static uint br = 0xFFFFFFFF;
public const uint br = 0xFFFFFFFF;

// lines to draw in a frame and vairables to go to new line
public double[] draw_lines = new double[1024 * 4 * 4];
Expand Down
8 changes: 4 additions & 4 deletions src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class Audio : ISoundProvider
private BlipBuffer _blip_L = new BlipBuffer(15000);
private BlipBuffer _blip_R = new BlipBuffer(15000);

public static bool[] DUTY_CYCLES = { false, false, false, false, false, false, false, true,
public static readonly bool[] DUTY_CYCLES = { false, false, false, false, false, false, false, true,
true, false, false, false, false, false, false, true,
true, false, false, false, false, true, true, true,
false, true, true, true, true, true, true, false };

public static int[] DIVISOR = { 8, 16, 32, 48, 64, 80, 96, 112 };
public static readonly int[] DIVISOR = { 8, 16, 32, 48, 64, 80, 96, 112 };

public const int NR10 = 0;
public const int NR11 = 1;
Expand All @@ -44,7 +44,7 @@ public class Audio : ISoundProvider
public const int NR51 = 19;
public const int NR52 = 20;

public static int[] unused_bits = { 0x80, 0x3F, 0x00, 0xFF, 0xBF,
public static readonly int[] unused_bits = { 0x80, 0x3F, 0x00, 0xFF, 0xBF,
0x3F, 0x00, 0xFF, 0xBF,
0x7F, 0xFF, 0x9F, 0xFF, 0xBF,
0xFF, 0x00, 0x00, 0xBF,
Expand Down Expand Up @@ -1249,4 +1249,4 @@ public void DisposeSound()
_blip_R = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private void MakeTrace(IntPtr _s)
},
_settings.RgbdsSyntax,
out _).PadRight(36),
#pragma warning disable CA2241
registerInfo: string.Format(
"A:{3:x2} F:{8:x2} B:{4:x2} C:{5:x2} D:{6:x2} E:{7:x2} H:{9:x2} L:{10:x2} LY:{13:x2} SP:{2:x2} {11} Cy:{0}",
(ulong)s[0] + _cycleCount,
Expand All @@ -57,6 +58,7 @@ private void MakeTrace(IntPtr _s)
s[11] != 0 ? "prefetched" : "",
s[12] & 0xffffff, // unused (this is the opcode)
s[13] & 0xff)));
#pragma warning restore CA2241
}
}
}
6 changes: 3 additions & 3 deletions src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ public byte ppubus_peek(int addr)
return nes.Board.PeekPPU(addr);
}

public static int PPU_PHASE_VBL = 0;
public static int PPU_PHASE_BG = 1;
public static int PPU_PHASE_OBJ = 2;
public const int PPU_PHASE_VBL = 0;
public const int PPU_PHASE_BG = 1;
public const int PPU_PHASE_OBJ = 2;

public int ppuphase;

Expand Down
Loading

0 comments on commit 8599fba

Please sign in to comment.