Skip to content

Commit f681ef3

Browse files
committed
Fix Qodana warnings
1 parent e6c75d2 commit f681ef3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33

44
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
55

6-
public static class PatchworkHelper
6+
public static partial class PatchworkHelper
77
{
8-
static int requiredMajor = ServerConfiguration.Instance.Authentication.PatchworkMajorVersionMinimum;
9-
static int requiredMinor = ServerConfiguration.Instance.Authentication.PatchworkMinorVersionMinimum;
8+
static readonly int requiredMajor = ServerConfiguration.Instance.Authentication.PatchworkMajorVersionMinimum;
9+
static readonly int requiredMinor = ServerConfiguration.Instance.Authentication.PatchworkMinorVersionMinimum;
10+
11+
[GeneratedRegex(@"^PatchworkLBP[123V] (\d{1,5})\.(\d{1,5})$")]
12+
private static partial Regex PatchworkUserAgentRegex();
13+
1014
public static bool IsValidPatchworkUserAgent(string userAgent)
1115
{
12-
Match result = Regex.Match(userAgent, @"^PatchworkLBP[123V] (\d{1,5})\.(\d{1,5})$");
16+
Match result = PatchworkUserAgentRegex().Match(userAgent);
1317
if (!result.Success) return false;
1418

1519
if (!int.TryParse(result.Groups[1].Value, out int major) || !int.TryParse(result.Groups[2].Value, out int minor))
1620
return false;
1721

18-
if (major < requiredMajor || minor < requiredMinor)
19-
return false;
20-
21-
return true;
22+
return major >= requiredMajor && minor >= requiredMinor;
2223
}
2324
}

ProjectLighthouse.Tests.GameApiTests/Unit/Helpers/PatchworkUserAgentTests.cs renamed to ProjectLighthouse.Tests.GameApiTests/Unit/PatchworkUserAgentTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using System;
21
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
32
using Xunit;
43

5-
namespace ProjectLighthouse.Tests.GameApiTests.Unit.Helpers;
4+
namespace ProjectLighthouse.Tests.GameApiTests.Unit;
65

76
[Trait("Category", "Unit")]
87
public class PatchworkUserAgentTests

0 commit comments

Comments
 (0)