< Summary - Jellyfin

Information
Class: Emby.Naming.Video.StubResolver
Assembly: Emby.Naming
File(s): /srv/git/jellyfin/Emby.Naming/Video/StubResolver.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 50
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TryResolveFile(...)100%88100%

File(s)

/srv/git/jellyfin/Emby.Naming/Video/StubResolver.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using Emby.Naming.Common;
 4using Jellyfin.Extensions;
 5
 6namespace Emby.Naming.Video
 7{
 8    /// <summary>
 9    /// Resolve if file is stub (.disc).
 10    /// </summary>
 11    public static class StubResolver
 12    {
 13        /// <summary>
 14        /// Tries to resolve if file is stub (.disc).
 15        /// </summary>
 16        /// <param name="path">Path to file.</param>
 17        /// <param name="options">NamingOptions containing StubFileExtensions and StubTypes.</param>
 18        /// <param name="stubType">Stub type.</param>
 19        /// <returns>True if file is a stub.</returns>
 20        public static bool TryResolveFile(string path, NamingOptions options, out string? stubType)
 21        {
 2122            stubType = default;
 23
 2124            if (string.IsNullOrEmpty(path))
 25            {
 126                return false;
 27            }
 28
 2029            var extension = Path.GetExtension(path.AsSpan());
 30
 2031            if (!options.StubFileExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
 32            {
 333                return false;
 34            }
 35
 1736            var token = Path.GetExtension(Path.GetFileNameWithoutExtension(path.AsSpan())).TrimStart('.');
 37
 19538            foreach (var rule in options.StubTypes)
 39            {
 8840                if (token.Equals(rule.Token, StringComparison.OrdinalIgnoreCase))
 41                {
 1542                    stubType = rule.StubType;
 1543                    return true;
 44                }
 45            }
 46
 247            return true;
 48        }
 49    }
 50}