< Summary - Jellyfin

Information
Class: Emby.Naming.Video.Format3DParser
Assembly: Emby.Naming
File(s): /srv/git/jellyfin/Emby.Naming/Video/Format3DParser.cs
Line coverage
100%
Covered lines: 29
Uncovered lines: 0
Coverable lines: 29
Total lines: 86
Line coverage: 100%
Branch coverage
93%
Covered branches: 15
Total branches: 16
Branch coverage: 93.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/6/2026 - 12:15:23 AM Line coverage: 100% (28/28) Branch coverage: 93.7% (15/16) Total lines: 817/29/2026 - 12:15:53 AM Line coverage: 100% (29/29) Branch coverage: 93.7% (15/16) Total lines: 86 5/6/2026 - 12:15:23 AM Line coverage: 100% (28/28) Branch coverage: 93.7% (15/16) Total lines: 817/29/2026 - 12:15:53 AM Line coverage: 100% (29/29) Branch coverage: 93.7% (15/16) Total lines: 86

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
Parse(...)100%11100%
Parse(...)100%44100%
Parse(...)91.66%1212100%

File(s)

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

#LineLine coverage
 1using System;
 2using Emby.Naming.Common;
 3
 4namespace Emby.Naming.Video
 5{
 6    /// <summary>
 7    /// Parse 3D format related flags.
 8    /// </summary>
 9    public static class Format3DParser
 10    {
 11        // Static default result to save on allocation costs.
 212        private static readonly Format3DResult _defaultResult = new(false, null);
 13
 14        /// <summary>
 15        /// Parse 3D format related flags.
 16        /// </summary>
 17        /// <param name="path">Path to file.</param>
 18        /// <param name="namingOptions">The naming options.</param>
 19        /// <returns>Returns <see cref="Format3DResult"/> object.</returns>
 20        public static Format3DResult Parse(ReadOnlySpan<char> path, NamingOptions namingOptions)
 21        {
 49722            int oldLen = namingOptions.VideoFlagDelimiters.Length;
 49723            Span<char> delimiters = stackalloc char[oldLen + 1];
 49724            namingOptions.VideoFlagDelimiters.AsSpan().CopyTo(delimiters);
 49725            delimiters[oldLen] = ' ';
 26
 49727            return Parse(path, delimiters, namingOptions);
 28        }
 29
 30        private static Format3DResult Parse(ReadOnlySpan<char> path, ReadOnlySpan<char> delimiters, NamingOptions naming
 31        {
 1237032            foreach (var rule in namingOptions.Format3DRules)
 33            {
 570534                var result = Parse(path, rule, delimiters);
 35
 570536                if (result.Is3D)
 37                {
 3438                    return result;
 39                }
 40            }
 41
 46342            return _defaultResult;
 43        }
 44
 45        private static Format3DResult Parse(ReadOnlySpan<char> path, Format3DRule rule, ReadOnlySpan<char> delimiters)
 46        {
 570547            bool is3D = false;
 570548            string? format3D = null;
 49
 50            // If there's no preceding token we just consider it found
 570551            var foundPrefix = string.IsNullOrEmpty(rule.PrecedingToken);
 5323352            while (path.Length > 0)
 53            {
 4756254                var index = path.IndexOfAny(delimiters);
 55                ReadOnlySpan<char> currentSlice;
 4756256                if (index == -1)
 57                {
 58                    // No delimiter left, the last token is the remainder of the path
 567659                    currentSlice = path;
 567660                    path = default;
 61                }
 62                else
 63                {
 4188664                    currentSlice = path[..index];
 4188665                    path = path[(index + 1)..];
 66                }
 67
 4756268                if (!foundPrefix)
 69                {
 1604970                    foundPrefix = currentSlice.Equals(rule.PrecedingToken, StringComparison.OrdinalIgnoreCase);
 1604971                    continue;
 72                }
 73
 3151374                is3D = foundPrefix && currentSlice.Equals(rule.Token, StringComparison.OrdinalIgnoreCase);
 75
 3151376                if (is3D)
 77                {
 3478                    format3D = rule.Token;
 3479                    break;
 80                }
 81            }
 82
 570583            return is3D ? new Format3DResult(true, format3D) : _defaultResult;
 84        }
 85    }
 86}