< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Sorting.OfficialRatingComparer
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
Line coverage
37%
Covered lines: 3
Uncovered lines: 5
Coverable lines: 8
Total lines: 45
Line coverage: 37.5%
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
.ctor(...)100%11100%
get_Type()100%11100%
Compare(...)0%2040%

File(s)

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

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System;
 4using Jellyfin.Data.Enums;
 5using MediaBrowser.Controller.Entities;
 6using MediaBrowser.Controller.Sorting;
 7using MediaBrowser.Model.Globalization;
 8using MediaBrowser.Model.Querying;
 9
 10namespace Emby.Server.Implementations.Sorting
 11{
 12    public class OfficialRatingComparer : IBaseItemComparer
 13    {
 14        private readonly ILocalizationManager _localization;
 15
 16        public OfficialRatingComparer(ILocalizationManager localization)
 17        {
 2218            _localization = localization;
 2219        }
 20
 21        /// <summary>
 22        /// Gets the name.
 23        /// </summary>
 24        /// <value>The name.</value>
 125        public ItemSortBy Type => ItemSortBy.OfficialRating;
 26
 27        /// <summary>
 28        /// Compares the specified x.
 29        /// </summary>
 30        /// <param name="x">The x.</param>
 31        /// <param name="y">The y.</param>
 32        /// <returns>System.Int32.</returns>
 33        public int Compare(BaseItem? x, BaseItem? y)
 34        {
 035            ArgumentNullException.ThrowIfNull(x);
 36
 037            ArgumentNullException.ThrowIfNull(y);
 38
 039            var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 
 040            var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 
 41
 042            return levelX.CompareTo(levelY);
 43        }
 44    }
 45}