refactor: remove redundant null checks
This commit is contained in:
1 parent
c0c6e0a38f
commit
14b938ea67
4 files changed
-28
No files matched your search
@@ -231,18 +231,6 @@ public sealed class FilenameParserTests {
|
||||
|
||||
#endregion
|
||||
|
||||
#region Argument validation
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that a null input is rejected.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void ThrowsForNullInput() {
|
||||
Assert.Throws<ArgumentNullException>(() => FilenameParser.Parse(null!));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Parses the input and asserts all three resulting fields.
|
||||
/// </summary>
|
||||
|
||||
@@ -114,15 +114,6 @@ public sealed class RenameFormatsTests {
|
||||
AssertStem(RenameFormat.ArtistFirst, " ", "Title", "\t", "Title");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that a null title is rejected.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void ThrowsForNullTitle() {
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => RenameFormats.GenerateStem(RenameFormat.ArtistFirst, "Artist", null!, "Live"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -109,10 +109,6 @@ public static class RenameFormats {
|
||||
/// Whitespace-only optional fields are treated as missing.
|
||||
/// </remarks>
|
||||
public static string GenerateStem(RenameFormat format, string artist, string title, string comment) {
|
||||
ArgumentNullException.ThrowIfNull(artist);
|
||||
ArgumentNullException.ThrowIfNull(title);
|
||||
ArgumentNullException.ThrowIfNull(comment);
|
||||
|
||||
RenameFormatDefinition definition = GetDefinition(format);
|
||||
bool hasArtist = !string.IsNullOrWhiteSpace(artist);
|
||||
bool hasComment = !string.IsNullOrWhiteSpace(comment);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -22,8 +21,6 @@ public static class FilenameParser {
|
||||
/// When no hyphen or more than one hyphen remains, the artist is empty and the whole text is the title.
|
||||
/// </remarks>
|
||||
public static FilenameParseResult Parse(string fileNameWithoutExtension) {
|
||||
ArgumentNullException.ThrowIfNull(fileNameWithoutExtension);
|
||||
|
||||
string source = fileNameWithoutExtension;
|
||||
string comment = string.Empty;
|
||||
|
||||
|
||||
Reference in new issue
Block a user