< Summary

Class:SearchHelper
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/SearchHandler/SearchHelper.cs
Covered lines:7
Uncovered lines:1
Coverable lines:8
Total lines:30
Line coverage:87.5% (7 of 8)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Search[T](...)0%2.152066.67%
SearchMatchItem[T](...)0%220100%
Sort[T](...)0%110100%
Filter[T](...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/SearchHandler/SearchHelper.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4
 5public static class SearchHelper
 6{
 7    public static List<T> Search<T>(string text, List<T> input) where T : ISearchable
 8    {
 29        if (string.IsNullOrEmpty(text))
 010            return new List<T>(input);
 11
 212        return input.FindAll(item => SearchMatchItem(text, item));
 13    }
 14
 15    public static bool SearchMatchItem<T>(string text, T item) where T : ISearchable
 16    {
 917        if (string.IsNullOrEmpty(text))
 118            return true;
 19
 20        // NOTE: Due to an Unity known issue, the use of 'StringComparison.OrdinalIgnoreCase' in WebGL is case sensitive
 21        // Absurd as it may seem, Unity says it is working in this way "by design", so it seems they're not going to fix
 22        // A work-around is to use '.ToLower()' in both strings.
 23        // More info: https://issuetracker.unity3d.com/issues/webgl-build-system-dot-stringcomparison-dot-ordinalignorec
 824        return item.keywords.Any(keyword => !string.IsNullOrEmpty(keyword) && keyword.ToLower().IndexOf(text.ToLower(), 
 25    }
 26
 5827    public static void Sort<T>(string sortType, List<T> input, bool descendingOrder) where T : ISortable<T> { input.Sort
 28
 2529    public static List<T> Filter<T>(List<T> input, Predicate<T> match) { return input.FindAll(match); }
 30}