< Summary - Jellyfin

Information
Class: Jellyfin.Extensions.DictionaryExtensions
Assembly: Jellyfin.Extensions
File(s): /srv/git/jellyfin/src/Jellyfin.Extensions/DictionaryExtensions.cs
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 45
Line coverage: 88.8%
Branch coverage
90%
Covered branches: 20
Total branches: 22
Branch coverage: 90.9%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 9/14/2025 - 12:09:49 AM Line coverage: 100% (9/9) Branch coverage: 100% (16/16) Total lines: 6411/28/2025 - 12:11:11 AM Line coverage: 88.8% (8/9) Branch coverage: 90.9% (20/22) Total lines: 45 9/14/2025 - 12:09:49 AM Line coverage: 100% (9/9) Branch coverage: 100% (16/16) Total lines: 6411/28/2025 - 12:11:11 AM Line coverage: 88.8% (8/9) Branch coverage: 90.9% (20/22) Total lines: 45

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetFirstNotNullNorWhiteSpaceValue(...)90.9%232288.88%

File(s)

/srv/git/jellyfin/src/Jellyfin.Extensions/DictionaryExtensions.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3namespace Jellyfin.Extensions
 4{
 5    /// <summary>
 6    /// Static extensions for the <see cref="IReadOnlyDictionary{TKey,TValue}"/> interface.
 7    /// </summary>
 8    public static class DictionaryExtensions
 9    {
 10        /// <summary>
 11        /// Gets a string from a string dictionary, checking all keys sequentially,
 12        /// stopping at the first key that returns a result that's neither null nor blank.
 13        /// </summary>
 14        /// <param name="dictionary">The dictionary.</param>
 15        /// <param name="key1">The first checked key.</param>
 16        /// <param name="key2">The second checked key.</param>
 17        /// <param name="key3">The third checked key.</param>
 18        /// <param name="key4">The fourth checked key.</param>
 19        /// <returns>System.String.</returns>
 20        public static string? GetFirstNotNullNorWhiteSpaceValue(this IReadOnlyDictionary<string, string> dictionary, str
 21        {
 6222            if (dictionary.TryGetValue(key1, out var val) && !string.IsNullOrWhiteSpace(val))
 23            {
 624                return val;
 25            }
 26
 5627            if (!string.IsNullOrEmpty(key2) && dictionary.TryGetValue(key2, out val) && !string.IsNullOrWhiteSpace(val))
 28            {
 229                return val;
 30            }
 31
 5432            if (!string.IsNullOrEmpty(key3) && dictionary.TryGetValue(key3, out val) && !string.IsNullOrWhiteSpace(val))
 33            {
 334                return val;
 35            }
 36
 5137            if (!string.IsNullOrEmpty(key4) && dictionary.TryGetValue(key4, out val) && !string.IsNullOrWhiteSpace(val))
 38            {
 039                return val;
 40            }
 41
 5142            return null;
 43        }
 44    }
 45}