< Summary

Class:ChannelUtils
Assembly:HUDUtils
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Utils/ChannelUtils.cs
Covered lines:9
Uncovered lines:0
Coverable lines:9
Total lines:36
Line coverage:100% (9 of 9)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ChannelUtils()0%110100%
ExtractChannelIdsFromText(...)0%330100%
IsAChannel(...)0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Utils/ChannelUtils.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Text.RegularExpressions;
 3
 4public class ChannelUtils
 5{
 6    private const string CHANNEL_MATCH_REGEX = "^#[a-zA-Z0-9-]{3,20}$";
 7    private const string NEAR_BY_CHANNEL = "~nearby";
 18    private static Regex filter = new Regex(CHANNEL_MATCH_REGEX);
 9
 10    public static List<string> ExtractChannelIdsFromText(string text)
 11    {
 212        List<string> channelsFound = new List<string>();
 13
 214        string[] separatedWords = text
 15            .Replace("<noparse>", "")
 16            .Replace("</noparse>", "")
 17            .Replace('\n', ' ')
 18            .Replace('.', ' ')
 19            .Replace(',', ' ')
 20            .Split(' ');
 21
 7622        for (int i = 0; i < separatedWords.Length; i++)
 23        {
 3624            if (IsAChannel(separatedWords[i]))
 825                channelsFound.Add(separatedWords[i]);
 26        }
 27
 228        return channelsFound;
 29    }
 30
 31    public static bool IsAChannel(string text)
 32    {
 3633        var match = filter.Match(text);
 3634        return match.Success || text.ToLower() == NEAR_BY_CHANNEL;
 35    }
 36}