< Summary

Class:SearchHelper
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/SearchHandler/SearchHelper.cs
Covered lines:6
Uncovered lines:2
Coverable lines:8
Total lines:30
Line coverage:75% (6 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%2.152066.67%
Sort[T](...)0%110100%
Filter[T](...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/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    {
 817        if (string.IsNullOrEmpty(text))
 018            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
 3427    public static void Sort<T>(string sortType, List<T> input, bool descendingOrder) where T : ISortable<T> { input.Sort
 28
 1429    public static List<T> Filter<T>(List<T> input, Predicate<T> match) { return input.FindAll(match); }
 30}