diff options
| author | Bond-009 <bond.009@outlook.com> | 2021-03-12 00:15:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-12 00:15:12 +0100 |
| commit | d7f0aaaec10aa642d1d73c87771c6089c19d0ab6 (patch) | |
| tree | 3e103444c61808a86d5b60604648e5eb5a074352 /Emby.Naming/Video/CleanStringParser.cs | |
| parent | e3adc9ab74abaaa00a40bba7614e8e42d63119ee (diff) | |
| parent | 5241bd41ef4917e0a3071f961f08dd2eeec5a5dd (diff) | |
Merge pull request #5417 from Bond-009/codeanal
Add code analysis attributes where appropriate
Diffstat (limited to 'Emby.Naming/Video/CleanStringParser.cs')
| -rw-r--r-- | Emby.Naming/Video/CleanStringParser.cs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs index bd7553a91..4eef3ebc5 100644 --- a/Emby.Naming/Video/CleanStringParser.cs +++ b/Emby.Naming/Video/CleanStringParser.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; namespace Emby.Naming.Video @@ -16,8 +17,14 @@ namespace Emby.Naming.Video /// <param name="expressions">List of regex to parse name and year from.</param> /// <param name="newName">Parsing result string.</param> /// <returns>True if parsing was successful.</returns> - public static bool TryClean(string name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName) + public static bool TryClean([NotNullWhen(true)] string? name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName) { + if (string.IsNullOrEmpty(name)) + { + newName = ReadOnlySpan<char>.Empty; + return false; + } + var len = expressions.Count; for (int i = 0; i < len; i++) { @@ -33,12 +40,6 @@ namespace Emby.Naming.Video private static bool TryClean(string name, Regex expression, out ReadOnlySpan<char> newName) { - if (string.IsNullOrEmpty(name)) - { - newName = ReadOnlySpan<char>.Empty; - return false; - } - var match = expression.Match(name); int index = match.Index; if (match.Success && index != 0) |
