mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09:00
Fixes code quality check failed
This commit is contained in:
parent
882223b27f
commit
8e79fac389
@ -12,79 +12,79 @@ namespace osu.Game.Tests.Online.Chat
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameMidlinePositive()
|
public void TestContainsUsernameMidlinePositive()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("This is a test message", "Test"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("This is a test message", "Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameStartOfLinePositive()
|
public void TestContainsUsernameStartOfLinePositive()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("Test message", "Test"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test message", "Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameEndOfLinePositive()
|
public void TestContainsUsernameEndOfLinePositive()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("This is a test", "Test"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("This is a test", "Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameMidlineNegative()
|
public void TestContainsUsernameMidlineNegative()
|
||||||
{
|
{
|
||||||
Assert.IsFalse(MessageNotifier.checkContainsUsername("This is a testmessage for notifications", "Test"));
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("This is a testmessage for notifications", "Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameStartOfLineNegative()
|
public void TestContainsUsernameStartOfLineNegative()
|
||||||
{
|
{
|
||||||
Assert.IsFalse(MessageNotifier.checkContainsUsername("Testmessage", "Test"));
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Testmessage", "Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameEndOfLineNegative()
|
public void TestContainsUsernameEndOfLineNegative()
|
||||||
{
|
{
|
||||||
Assert.IsFalse(MessageNotifier.checkContainsUsername("This is a notificationtest", "Test"));
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("This is a notificationtest", "Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameBetweenInterpunction()
|
public void TestContainsUsernameBetweenInterpunction()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("Hello 'test'-message", "Test"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Hello 'test'-message", "Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameUnicode()
|
public void TestContainsUsernameUnicode()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("Test \u0460\u0460 message", "\u0460\u0460"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test \u0460\u0460 message", "\u0460\u0460"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameUnicodeNegative()
|
public void TestContainsUsernameUnicodeNegative()
|
||||||
{
|
{
|
||||||
Assert.IsFalse(MessageNotifier.checkContainsUsername("Test ha\u0460\u0460o message", "\u0460\u0460"));
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Test ha\u0460\u0460o message", "\u0460\u0460"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameSpecialCharactersPositive()
|
public void TestContainsUsernameSpecialCharactersPositive()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("Test [#^-^#] message", "[#^-^#]"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("Test [#^-^#] message", "[#^-^#]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameSpecialCharactersNegative()
|
public void TestContainsUsernameSpecialCharactersNegative()
|
||||||
{
|
{
|
||||||
Assert.IsFalse(MessageNotifier.checkContainsUsername("Test pad[#^-^#]oru message", "[#^-^#]"));
|
Assert.IsFalse(MessageNotifier.CheckContainsUsername("Test pad[#^-^#]oru message", "[#^-^#]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameAtSign()
|
public void TestContainsUsernameAtSign()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("@username hi", "username"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("@username hi", "username"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestContainsUsernameColon()
|
public void TestContainsUsernameColon()
|
||||||
{
|
{
|
||||||
Assert.IsTrue(MessageNotifier.checkContainsUsername("username: hi", "username"));
|
Assert.IsTrue(MessageNotifier.CheckContainsUsername("username: hi", "username"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -121,7 +120,7 @@ namespace osu.Game.Online.Chat
|
|||||||
|
|
||||||
private void checkForMentions(Channel channel, Message message)
|
private void checkForMentions(Channel channel, Message message)
|
||||||
{
|
{
|
||||||
if (!notifyOnUsername.Value || !checkContainsUsername(message.Content, localUser.Value.Username)) return;
|
if (!notifyOnUsername.Value || !CheckContainsUsername(message.Content, localUser.Value.Username)) return;
|
||||||
|
|
||||||
notifications.Post(new MentionNotification(message.Sender.Username, channel));
|
notifications.Post(new MentionNotification(message.Sender.Username, channel));
|
||||||
}
|
}
|
||||||
@ -130,7 +129,7 @@ namespace osu.Game.Online.Chat
|
|||||||
/// Checks if <paramref name="message"/> mentions <paramref name="username"/>.
|
/// Checks if <paramref name="message"/> mentions <paramref name="username"/>.
|
||||||
/// This will match against the case where underscores are used instead of spaces (which is how osu-stable handles usernames with spaces).
|
/// This will match against the case where underscores are used instead of spaces (which is how osu-stable handles usernames with spaces).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool checkContainsUsername(string message, string username)
|
public static bool CheckContainsUsername(string message, string username)
|
||||||
{
|
{
|
||||||
string fullName = Regex.Escape(username);
|
string fullName = Regex.Escape(username);
|
||||||
string underscoreName = Regex.Escape(username.Replace(' ', '_'));
|
string underscoreName = Regex.Escape(username.Replace(' ', '_'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user