< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.MediaSourceWidthComparator
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/MediaSourceWidthComparator.cs
Line coverage
29%
Covered lines: 5
Uncovered lines: 12
Coverable lines: 17
Total lines: 56
Line coverage: 29.4%
Branch coverage
27%
Covered branches: 5
Total branches: 18
Branch coverage: 27.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 3/26/2026 - 12:14:14 AM Line coverage: 0% (0/17) Branch coverage: 0% (0/18) Total lines: 567/6/2026 - 12:16:28 AM Line coverage: 29.4% (5/17) Branch coverage: 27.7% (5/18) Total lines: 56 3/26/2026 - 12:14:14 AM Line coverage: 0% (0/17) Branch coverage: 0% (0/18) Total lines: 567/6/2026 - 12:16:28 AM Line coverage: 29.4% (5/17) Branch coverage: 27.7% (5/18) Total lines: 56

Coverage delta

Coverage delta 30 -30

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Compare(...)27.77%1321829.41%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/MediaSourceWidthComparator.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Runtime.Intrinsics.X86;
 4using MediaBrowser.Model.Dto;
 5
 6namespace MediaBrowser.Controller.Entities;
 7
 8/// <summary>
 9/// Compare MediaSource of the same file by Video width <see cref="IComparer{T}" />.
 10/// </summary>
 11public class MediaSourceWidthComparator : IComparer<MediaSourceInfo>
 12{
 13    /// <inheritdoc />
 14    public int Compare(MediaSourceInfo? x, MediaSourceInfo? y)
 15    {
 616        if (x is null && y is null)
 17        {
 018            return 0;
 19        }
 20
 621        if (x is null)
 22        {
 023            return -1;
 24        }
 25
 626        if (y is null)
 27        {
 028            return 1;
 29        }
 30
 631        if (string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase))
 32        {
 033            if (x.VideoStream is null && y.VideoStream is null)
 34            {
 035                return 0;
 36            }
 37
 038            if (x.VideoStream is null)
 39            {
 040                return -1;
 41            }
 42
 043            if (y.VideoStream is null)
 44            {
 045                return 1;
 46            }
 47
 048            var xWidth = x.VideoStream.Width ?? 0;
 049            var yWidth = y.VideoStream.Width ?? 0;
 50
 051            return xWidth - yWidth;
 52        }
 53
 654        return 0;
 55    }
 56}