< Summary

Class:DCL.Chat.Channels.ChannelUtils
Assembly:ChatController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ChatController/Channels/ChannelUtils.cs
Covered lines:9
Uncovered lines:0
Coverable lines:9
Total lines:39
Line coverage:100% (9 of 9)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:3
Method coverage:100% (3 of 3)

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/ChatController/Channels/ChannelUtils.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Text.RegularExpressions;
 3
 4namespace DCL.Chat.Channels
 5{
 6    public static class ChannelUtils
 7    {
 8        private const string CHANNEL_MATCH_REGEX = "^#[a-zA-Z0-9-]{3,20}$";
 9        private const string NEAR_BY_CHANNEL = "~nearby";
 110        private static readonly Regex filter = new (CHANNEL_MATCH_REGEX);
 11
 12        public static List<string> ExtractChannelIdsFromText(string text)
 13        {
 214            List<string> channelsFound = new List<string>();
 15
 216            string[] separatedWords = text
 17                                     .Replace("<noparse>", "")
 18                                     .Replace("</noparse>", "")
 19                                     .Replace('\n', ' ')
 20                                     .Replace('.', ' ')
 21                                     .Replace(',', ' ')
 22                                     .Split(' ');
 23
 7624            for (int i = 0; i < separatedWords.Length; i++)
 25            {
 3626                if (IsAChannel(separatedWords[i]))
 827                    channelsFound.Add(separatedWords[i]);
 28            }
 29
 230            return channelsFound;
 31        }
 32
 33        public static bool IsAChannel(string text)
 34        {
 3635            var match = filter.Match(text);
 3636            return match.Success || text.ToLower() == NEAR_BY_CHANNEL;
 37        }
 38    }
 39}