< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.TagExtensions
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/TagExtensions.cs
Line coverage
62%
Covered lines: 5
Uncovered lines: 3
Coverable lines: 8
Total lines: 33
Line coverage: 62.5%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
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
AddTag(...)50%7.9662.5%

File(s)

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

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System;
 4using System.Linq;
 5using Jellyfin.Extensions;
 6
 7namespace MediaBrowser.Controller.Entities
 8{
 9    public static class TagExtensions
 10    {
 11        public static void AddTag(this BaseItem item, string name)
 12        {
 213            if (string.IsNullOrWhiteSpace(name))
 14            {
 015                throw new ArgumentNullException(nameof(name));
 16            }
 17
 218            var current = item.Tags;
 19
 220            if (!current.Contains(name, StringComparison.OrdinalIgnoreCase))
 21            {
 222                if (current.Length == 0)
 23                {
 224                    item.Tags = [name];
 25                }
 26                else
 27                {
 028                    item.Tags = [..current, name];
 29                }
 30            }
 031        }
 32    }
 33}