From 7cb3d7445cdd42c32c4a6dc995d8383878c60e16 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Tue, 2 Jul 2024 17:20:00 -0300 Subject: [PATCH 1/9] Add verify checks for title markers --- .../Editing/Checks/CheckTitleMarkersTest.cs | 235 ++++++++++++++++++ osu.Game/Rulesets/Edit/BeatmapVerifier.cs | 3 + .../Rulesets/Edit/Checks/CheckTitleMarkers.cs | 76 ++++++ 3 files changed, 314 insertions(+) create mode 100644 osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs create mode 100644 osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs diff --git a/osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs b/osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs new file mode 100644 index 000000000000..54d313670066 --- /dev/null +++ b/osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs @@ -0,0 +1,235 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Objects; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Tests.Editing.Checks +{ + [TestFixture] + public class CheckTitleMarkersTest + { + private CheckTitleMarkers check = null!; + + private IBeatmap beatmap = null!; + + [SetUp] + public void Setup() + { + check = new CheckTitleMarkers(); + + beatmap = new Beatmap + { + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Title = "Egao no Kanata", + TitleUnicode = "エガオノカナタ" + } + } + }; + } + + [Test] + public void TestNoTitleMarkers() + { + var issues = check.Run(getContext(beatmap)).ToList(); + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestTVSizeMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (TV Size)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (TV Size)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedTVSizeMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (tv size)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (tv size)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + [Test] + public void TestGameVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (Game Ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Game Ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedGameVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (game ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (game ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + [Test] + public void TestShortVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (Short Ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Short Ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedShortVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (short ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (short ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + [Test] + public void TestCutVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (Cut Ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Cut Ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedCutVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (cut ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (cut ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + [Test] + public void TestSpedUpVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (Sped Up Ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Sped Up Ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedSpedUpVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (sped up ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (sped up ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + [Test] + public void TestNightcoreMixMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (Nightcore Mix)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Nightcore Mix)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedNightcoreMixMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (nightcore mix)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (nightcore mix)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + [Test] + public void TestSpedUpCutVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (Sped Up & Cut Ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Sped Up & Cut Ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedSpedUpCutVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (sped up & cut ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (sped up & cut ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + [Test] + public void TestNightcoreCutVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (Nightcore & Cut Ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (Nightcore & Cut Ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestMalformedNightcoreCutVerMarker() + { + beatmap.BeatmapInfo.Metadata.Title += " (nightcore & cut ver.)"; + beatmap.BeatmapInfo.Metadata.TitleUnicode += " (nightcore & cut ver.)"; + + var issues = check.Run(getContext(beatmap)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(2)); + Assert.That(issues.Any(issue => issue.Template is CheckTitleMarkers.IssueTemplateIncorrectMarker)); + } + + private BeatmapVerifierContext getContext(IBeatmap beatmap) + { + return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); + } + } +} \ No newline at end of file diff --git a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs index a9681e13bafa..642b878a7b8c 100644 --- a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs +++ b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs @@ -46,6 +46,9 @@ public class BeatmapVerifier : IBeatmapVerifier // Events new CheckBreaks(), + + // Metadata + new CheckTitleMarkers(), }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs new file mode 100644 index 000000000000..6753abde4de6 --- /dev/null +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -0,0 +1,76 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.Text.RegularExpressions; +using osu.Game.Rulesets.Edit.Checks.Components; + +namespace osu.Game.Rulesets.Edit.Checks +{ + public class CheckTitleMarkers : ICheck + { + public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Metadata, "Checks for incorrect formats of (TV Size) / (Game Ver.) / (Short Ver.) / (Cut Ver.) / (Sped Up Ver.) / etc in title."); + + public IEnumerable PossibleTemplates => new IssueTemplate[] + { + new IssueTemplateIncorrectMarker(this), + }; + + public IEnumerable MarkerChecks => new MarkerCheck[] + { + new MarkerCheck("(TV Size)", @"(?i)(tv (size|ver))"), + new MarkerCheck("(Game Ver.)", @"(?i)(game (size|ver))"), + new MarkerCheck("(Short Ver.)", @"(?i)(short (size|ver))"), + new MarkerCheck("(Cut Ver.)", @"(?i)(? Run(BeatmapVerifierContext context) + { + string romanisedTitle = context.Beatmap.Metadata.Title; + string unicodeTitle = context.Beatmap.Metadata.TitleUnicode; + + foreach (var check in MarkerChecks) + { + bool hasRomanisedTitle = unicodeTitle != romanisedTitle; + + if (check.AnyRegex.IsMatch(romanisedTitle) && !check.ExactRegex.IsMatch(romanisedTitle)) + { + yield return new IssueTemplateIncorrectMarker(this).Create(hasRomanisedTitle ? "Romanised title" : "Title", check.CorrectMarkerFormat); + } + + if (hasRomanisedTitle && check.AnyRegex.IsMatch(unicodeTitle) && !check.ExactRegex.IsMatch(unicodeTitle)) + { + yield return new IssueTemplateIncorrectMarker(this).Create("Title", check.CorrectMarkerFormat); + } + } + } + + public class MarkerCheck + { + public string CorrectMarkerFormat; + public Regex ExactRegex; + public Regex AnyRegex; + + public MarkerCheck(string exact, string anyRegex) + { + CorrectMarkerFormat = exact; + ExactRegex = new Regex(Regex.Escape(exact)); + AnyRegex = new Regex(anyRegex); + } + } + + public class IssueTemplateIncorrectMarker : IssueTemplate + { + public IssueTemplateIncorrectMarker(ICheck check) + : base(check, IssueType.Problem, "{0} field has a incorrect format of marker {1}") + { + } + + public Issue Create(string titleField, string correctMarkerFormat) => new Issue(this, titleField, correctMarkerFormat); + } + } +} \ No newline at end of file From 7cdad20119481ba3ff48001a08ee3f1abb58fc71 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Tue, 2 Jul 2024 20:55:52 -0300 Subject: [PATCH 2/9] Fix explicit array type specification in MarkerChecks --- osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index 6753abde4de6..6e5faf3daeae 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -16,8 +16,7 @@ public class CheckTitleMarkers : ICheck new IssueTemplateIncorrectMarker(this), }; - public IEnumerable MarkerChecks => new MarkerCheck[] - { + public IEnumerable MarkerChecks = [ new MarkerCheck("(TV Size)", @"(?i)(tv (size|ver))"), new MarkerCheck("(Game Ver.)", @"(?i)(game (size|ver))"), new MarkerCheck("(Short Ver.)", @"(?i)(short (size|ver))"), @@ -26,7 +25,7 @@ public class CheckTitleMarkers : ICheck new MarkerCheck("(Nightcore Mix)", @"(?i)(? Run(BeatmapVerifierContext context) { From 7143ff523fb9155ca7ed10e3f02d3ed38bef138b Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Tue, 2 Jul 2024 21:09:49 -0300 Subject: [PATCH 3/9] Make `MarkerChecks` and `MarkerCheck` class private --- osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index 6e5faf3daeae..2471d175aef0 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -16,7 +16,7 @@ public class CheckTitleMarkers : ICheck new IssueTemplateIncorrectMarker(this), }; - public IEnumerable MarkerChecks = [ + private IEnumerable markerChecks = [ new MarkerCheck("(TV Size)", @"(?i)(tv (size|ver))"), new MarkerCheck("(Game Ver.)", @"(?i)(game (size|ver))"), new MarkerCheck("(Short Ver.)", @"(?i)(short (size|ver))"), @@ -32,7 +32,7 @@ public IEnumerable Run(BeatmapVerifierContext context) string romanisedTitle = context.Beatmap.Metadata.Title; string unicodeTitle = context.Beatmap.Metadata.TitleUnicode; - foreach (var check in MarkerChecks) + foreach (var check in markerChecks) { bool hasRomanisedTitle = unicodeTitle != romanisedTitle; @@ -48,7 +48,7 @@ public IEnumerable Run(BeatmapVerifierContext context) } } - public class MarkerCheck + private class MarkerCheck { public string CorrectMarkerFormat; public Regex ExactRegex; From 21829e7ef46bc3dcc91ca5677ed837bbdb024d8a Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Tue, 2 Jul 2024 21:12:15 -0300 Subject: [PATCH 4/9] Fix test method names --- osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs b/osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs index 54d313670066..a8f86a6d459a 100644 --- a/osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckTitleMarkersTest.cs @@ -44,7 +44,7 @@ public void TestNoTitleMarkers() } [Test] - public void TestTVSizeMarker() + public void TestTvSizeMarker() { beatmap.BeatmapInfo.Metadata.Title += " (TV Size)"; beatmap.BeatmapInfo.Metadata.TitleUnicode += " (TV Size)"; @@ -55,7 +55,7 @@ public void TestTVSizeMarker() } [Test] - public void TestMalformedTVSizeMarker() + public void TestMalformedTvSizeMarker() { beatmap.BeatmapInfo.Metadata.Title += " (tv size)"; beatmap.BeatmapInfo.Metadata.TitleUnicode += " (tv size)"; From 901fec65efd57b347948e388c31ce71c67fe0662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 3 Jul 2024 15:49:17 +0200 Subject: [PATCH 5/9] Address code quality issues --- .../Rulesets/Edit/Checks/CheckTitleMarkers.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index 2471d175aef0..d6fd771e9c39 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -16,15 +16,16 @@ public class CheckTitleMarkers : ICheck new IssueTemplateIncorrectMarker(this), }; - private IEnumerable markerChecks = [ - new MarkerCheck("(TV Size)", @"(?i)(tv (size|ver))"), - new MarkerCheck("(Game Ver.)", @"(?i)(game (size|ver))"), - new MarkerCheck("(Short Ver.)", @"(?i)(short (size|ver))"), - new MarkerCheck("(Cut Ver.)", @"(?i)(? markerChecks = + [ + new MarkerCheck(@"(TV Size)", @"(?i)(tv (size|ver))"), + new MarkerCheck(@"(Game Ver.)", @"(?i)(game (size|ver))"), + new MarkerCheck(@"(Short Ver.)", @"(?i)(short (size|ver))"), + new MarkerCheck(@"(Cut Ver.)", @"(?i)(? Run(BeatmapVerifierContext context) @@ -50,9 +51,9 @@ public IEnumerable Run(BeatmapVerifierContext context) private class MarkerCheck { - public string CorrectMarkerFormat; - public Regex ExactRegex; - public Regex AnyRegex; + public readonly string CorrectMarkerFormat; + public readonly Regex ExactRegex; + public readonly Regex AnyRegex; public MarkerCheck(string exact, string anyRegex) { @@ -72,4 +73,4 @@ public IssueTemplateIncorrectMarker(ICheck check) public Issue Create(string titleField, string correctMarkerFormat) => new Issue(this, titleField, correctMarkerFormat); } } -} \ No newline at end of file +} From 32b3d3d7dfefdffcef5698acd47df4e964ba6a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 3 Jul 2024 15:49:21 +0200 Subject: [PATCH 6/9] Compile regexes for speed --- osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index d6fd771e9c39..fb0203fe191e 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -58,8 +58,8 @@ private class MarkerCheck public MarkerCheck(string exact, string anyRegex) { CorrectMarkerFormat = exact; - ExactRegex = new Regex(Regex.Escape(exact)); - AnyRegex = new Regex(anyRegex); + ExactRegex = new Regex(Regex.Escape(exact), RegexOptions.Compiled); + AnyRegex = new Regex(anyRegex, RegexOptions.Compiled); } } From 5696e85b68d3a343ea89a4b56d6d13d54fd11c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 3 Jul 2024 15:50:36 +0200 Subject: [PATCH 7/9] Adjust conditionals The fact that checking the unicode title was gated behind a `hasRomanisedTitle` guard was breaking my brain. --- osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index fb0203fe191e..b6339851ef5e 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -37,15 +37,11 @@ public IEnumerable Run(BeatmapVerifierContext context) { bool hasRomanisedTitle = unicodeTitle != romanisedTitle; - if (check.AnyRegex.IsMatch(romanisedTitle) && !check.ExactRegex.IsMatch(romanisedTitle)) - { - yield return new IssueTemplateIncorrectMarker(this).Create(hasRomanisedTitle ? "Romanised title" : "Title", check.CorrectMarkerFormat); - } - - if (hasRomanisedTitle && check.AnyRegex.IsMatch(unicodeTitle) && !check.ExactRegex.IsMatch(unicodeTitle)) - { + if (check.AnyRegex.IsMatch(unicodeTitle) && !check.ExactRegex.IsMatch(unicodeTitle)) yield return new IssueTemplateIncorrectMarker(this).Create("Title", check.CorrectMarkerFormat); - } + + if (hasRomanisedTitle && check.AnyRegex.IsMatch(romanisedTitle) && !check.ExactRegex.IsMatch(romanisedTitle)) + yield return new IssueTemplateIncorrectMarker(this).Create("Romanised title", check.CorrectMarkerFormat); } } From bcb479d4f70d7f268dc54b4f6265ad2b40496507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 3 Jul 2024 16:13:30 +0200 Subject: [PATCH 8/9] Use one less regex --- osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index b6339851ef5e..00482a72fc00 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.Text.RegularExpressions; using osu.Game.Rulesets.Edit.Checks.Components; @@ -37,10 +38,10 @@ public IEnumerable Run(BeatmapVerifierContext context) { bool hasRomanisedTitle = unicodeTitle != romanisedTitle; - if (check.AnyRegex.IsMatch(unicodeTitle) && !check.ExactRegex.IsMatch(unicodeTitle)) + if (check.AnyRegex.IsMatch(unicodeTitle) && !unicodeTitle.Contains(check.CorrectMarkerFormat, StringComparison.Ordinal)) yield return new IssueTemplateIncorrectMarker(this).Create("Title", check.CorrectMarkerFormat); - if (hasRomanisedTitle && check.AnyRegex.IsMatch(romanisedTitle) && !check.ExactRegex.IsMatch(romanisedTitle)) + if (hasRomanisedTitle && check.AnyRegex.IsMatch(romanisedTitle) && !romanisedTitle.Contains(check.CorrectMarkerFormat, StringComparison.Ordinal)) yield return new IssueTemplateIncorrectMarker(this).Create("Romanised title", check.CorrectMarkerFormat); } } @@ -48,13 +49,11 @@ public IEnumerable Run(BeatmapVerifierContext context) private class MarkerCheck { public readonly string CorrectMarkerFormat; - public readonly Regex ExactRegex; public readonly Regex AnyRegex; public MarkerCheck(string exact, string anyRegex) { CorrectMarkerFormat = exact; - ExactRegex = new Regex(Regex.Escape(exact), RegexOptions.Compiled); AnyRegex = new Regex(anyRegex, RegexOptions.Compiled); } } From 00a0058fc709320e3dc1bea4053ee3fb30c94397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 3 Jul 2024 16:13:47 +0200 Subject: [PATCH 9/9] Fix typo --- osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index 00482a72fc00..9c702ad58a0c 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -61,7 +61,7 @@ public MarkerCheck(string exact, string anyRegex) public class IssueTemplateIncorrectMarker : IssueTemplate { public IssueTemplateIncorrectMarker(ICheck check) - : base(check, IssueType.Problem, "{0} field has a incorrect format of marker {1}") + : base(check, IssueType.Problem, "{0} field has an incorrect format of marker {1}") { }