< Summary - Jellyfin

Information
Class: Emby.Naming.Common.EpisodeExpression
Assembly: Emby.Naming
File(s): /srv/git/jellyfin/Emby.Naming/Common/EpisodeExpression.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 70
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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_Expression()100%11100%
set_Expression(...)100%11100%
get_Regex()100%22100%

File(s)

/srv/git/jellyfin/Emby.Naming/Common/EpisodeExpression.cs

#LineLine coverage
 1using System;
 2using System.Text.RegularExpressions;
 3
 4namespace Emby.Naming.Common
 5{
 6    /// <summary>
 7    /// Regular expressions for parsing TV Episodes.
 8    /// </summary>
 9    public class EpisodeExpression
 10    {
 11        private string _expression;
 12        private Regex? _regex;
 13
 14        /// <summary>
 15        /// Initializes a new instance of the <see cref="EpisodeExpression"/> class.
 16        /// </summary>
 17        /// <param name="expression">Regular expressions.</param>
 18        /// <param name="byDate">True if date is expected.</param>
 19        public EpisodeExpression(string expression, bool byDate = false)
 20        {
 2204021            _expression = expression;
 2204022            IsByDate = byDate;
 2204023            DateTimeFormats = Array.Empty<string>();
 2204024            SupportsAbsoluteEpisodeNumbers = true;
 2204025        }
 26
 27        /// <summary>
 28        /// Gets or sets raw expressions string.
 29        /// </summary>
 30        public string Expression
 31        {
 628332            get => _expression;
 33            set
 34            {
 10935                _expression = value;
 10936                _regex = null;
 10937            }
 38        }
 39
 40        /// <summary>
 41        /// Gets or sets a value indicating whether gets or sets property indicating if date can be find in expression.
 42        /// </summary>
 43        public bool IsByDate { get; set; }
 44
 45        /// <summary>
 46        /// Gets or sets a value indicating whether gets or sets property indicating if expression is optimistic.
 47        /// </summary>
 48        public bool IsOptimistic { get; set; }
 49
 50        /// <summary>
 51        /// Gets or sets a value indicating whether gets or sets property indicating if expression is named.
 52        /// </summary>
 53        public bool IsNamed { get; set; }
 54
 55        /// <summary>
 56        /// Gets or sets a value indicating whether gets or sets property indicating if expression supports episodes wit
 57        /// </summary>
 58        public bool SupportsAbsoluteEpisodeNumbers { get; set; }
 59
 60        /// <summary>
 61        /// Gets or sets optional list of date formats used for date parsing.
 62        /// </summary>
 63        public string[] DateTimeFormats { get; set; }
 64
 65        /// <summary>
 66        /// Gets a <see cref="Regex"/> expressions objects (creates it if null).
 67        /// </summary>
 701068        public Regex Regex => _regex ??= new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled);
 69    }
 70}