From 468c9937da404b2a9a6ed3bcea7c50c911010dc7 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 5 Nov 2024 15:30:54 -0500 Subject: [PATCH] Reduce null use in BaseProcessor --- CHANGELIST.md | 1 + MPF.Processors/BaseProcessor.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 3d9ee757..b6e25602 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -40,6 +40,7 @@ - Add conf to build matrix - Ensure debug symbols are stripped - Fix missed GetOutputFiles invocation +- Reduce null use in BaseProcessor ### 3.2.2 (2024-09-24) diff --git a/MPF.Processors/BaseProcessor.cs b/MPF.Processors/BaseProcessor.cs index c2db1fd3..9b431227 100644 --- a/MPF.Processors/BaseProcessor.cs +++ b/MPF.Processors/BaseProcessor.cs @@ -207,7 +207,7 @@ namespace MPF.Processors public Dictionary GenerateArtifacts(string basePath) { // Split the base path for matching - string? baseDirectory = Path.GetDirectoryName(basePath); + string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; string baseFilename = Path.GetFileNameWithoutExtension(basePath); // Get the list of output files @@ -228,7 +228,7 @@ namespace MPF.Processors // Skip non-existent files foreach (string filename in outputFile.Filenames) { - string possibleFile = Path.Combine(baseDirectory ?? string.Empty, filename); + string possibleFile = Path.Combine(baseDirectory, filename); if (!File.Exists(possibleFile)) continue; @@ -332,7 +332,7 @@ namespace MPF.Processors private List CheckRequiredFiles(string basePath) { // Split the base path for matching - string? baseDirectory = Path.GetDirectoryName(basePath); + string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; string baseFilename = Path.GetFileNameWithoutExtension(basePath); // Get the list of output files @@ -370,7 +370,7 @@ namespace MPF.Processors continue; // Use the built-in existence function - if (outputFile.Exists(baseDirectory ?? string.Empty)) + if (outputFile.Exists(baseDirectory)) continue; // If the log archive doesn't exist @@ -404,7 +404,7 @@ namespace MPF.Processors private List GetDeleteableFilenames(string basePath) { // Split the base path for matching - string? baseDirectory = Path.GetDirectoryName(basePath); + string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; string baseFilename = Path.GetFileNameWithoutExtension(basePath); // Get the list of output files @@ -509,7 +509,7 @@ namespace MPF.Processors private List GetZippableFilenames(string basePath) { // Split the base path for matching - string? baseDirectory = Path.GetDirectoryName(basePath); + string baseDirectory = Path.GetDirectoryName(basePath) ?? string.Empty; string baseFilename = Path.GetFileNameWithoutExtension(basePath); // Get the list of output files