< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Sorting.ArtistComparer
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Sorting/ArtistComparer.cs
Line coverage
20%
Covered lines: 1
Uncovered lines: 4
Coverable lines: 5
Total lines: 39
Line coverage: 20%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
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
get_Type()100%11100%
Compare(...)100%210%
GetValue(...)0%2040%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Sorting/ArtistComparer.cs

#LineLine coverage
 1using System;
 2using Jellyfin.Data.Enums;
 3using MediaBrowser.Controller.Entities;
 4using MediaBrowser.Controller.Entities.Audio;
 5using MediaBrowser.Controller.Sorting;
 6using MediaBrowser.Model.Querying;
 7
 8namespace Emby.Server.Implementations.Sorting
 9{
 10    /// <summary>
 11    /// Class ArtistComparer.
 12    /// </summary>
 13    public class ArtistComparer : IBaseItemComparer
 14    {
 15        /// <inheritdoc />
 116        public ItemSortBy Type => ItemSortBy.Artist;
 17
 18        /// <inheritdoc />
 19        public int Compare(BaseItem? x, BaseItem? y)
 20        {
 021            return string.Compare(GetValue(x), GetValue(y), StringComparison.OrdinalIgnoreCase);
 22        }
 23
 24        /// <summary>
 25        /// Gets the value.
 26        /// </summary>
 27        /// <param name="x">The x.</param>
 28        /// <returns>System.String.</returns>
 29        private static string? GetValue(BaseItem? x)
 30        {
 031            if (x is not Audio audio)
 32            {
 033                return string.Empty;
 34            }
 35
 036            return audio.Artists.Count == 0 ? null : audio.Artists[0];
 37        }
 38    }
 39}