From 7d31eb1f55006ac57cb55174f97faa20ad259a7a Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 2 Oct 2020 14:52:48 -0400 Subject: [PATCH] Fixed: Test for empty strings using isNullOrEmpty --- .editorconfig | 2 -- src/NzbDrone.Common/OAuth/OAuthRequest.cs | 4 ++-- src/NzbDrone.Common/OAuth/OAuthTools.cs | 2 +- src/NzbDrone.Common/TinyIoC.cs | 2 +- .../Datastore/Migration/149_convert_regex_required_tags.cs | 4 ++-- .../Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs | 2 +- src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs | 2 +- src/NzbDrone.Core/Parser/IsoLanguages.cs | 2 +- src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs | 2 +- 9 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9bec013f1..ba00f5fd8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -185,8 +185,6 @@ dotnet_diagnostic.CA1814.severity = suggestion dotnet_diagnostic.CA1815.severity = suggestion dotnet_diagnostic.CA1816.severity = suggestion dotnet_diagnostic.CA1819.severity = suggestion -dotnet_diagnostic.CA1820.severity = suggestion -dotnet_diagnostic.CA1821.severity = suggestion dotnet_diagnostic.CA1822.severity = suggestion dotnet_diagnostic.CA1823.severity = suggestion dotnet_diagnostic.CA1824.severity = suggestion diff --git a/src/NzbDrone.Common/OAuth/OAuthRequest.cs b/src/NzbDrone.Common/OAuth/OAuthRequest.cs index 7f84d9e7f..cdf7d9e1f 100644 --- a/src/NzbDrone.Common/OAuth/OAuthRequest.cs +++ b/src/NzbDrone.Common/OAuth/OAuthRequest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; @@ -488,7 +488,7 @@ namespace NzbDrone.Common.OAuth private static bool IsNullOrBlank(string value) { - return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && value.Trim() == string.Empty); + return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && string.IsNullOrEmpty(value.Trim())); } } } diff --git a/src/NzbDrone.Common/OAuth/OAuthTools.cs b/src/NzbDrone.Common/OAuth/OAuthTools.cs index c2b14c519..20ea671b6 100644 --- a/src/NzbDrone.Common/OAuth/OAuthTools.cs +++ b/src/NzbDrone.Common/OAuth/OAuthTools.cs @@ -405,7 +405,7 @@ namespace NzbDrone.Common.OAuth private static bool IsNullOrBlank(string value) { - return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && value.Trim() == string.Empty); + return string.IsNullOrEmpty(value) || (!string.IsNullOrEmpty(value) && string.IsNullOrEmpty(value.Trim())); } } } diff --git a/src/NzbDrone.Common/TinyIoC.cs b/src/NzbDrone.Common/TinyIoC.cs index b61d91cde..a9750319d 100644 --- a/src/NzbDrone.Common/TinyIoC.cs +++ b/src/NzbDrone.Common/TinyIoC.cs @@ -3660,7 +3660,7 @@ namespace TinyIoC var registrations = _RegisteredTypes.Keys.Where(tr => tr.Type == resolveType).Concat(GetParentRegistrationsForType(resolveType)); if (!includeUnnamed) - registrations = registrations.Where(tr => tr.Name != string.Empty); + registrations = registrations.Where(tr => !string.IsNullOrEmpty(tr.Name)); return registrations.Select(registration => this.ResolveInternal(registration, NamedParameterOverloads.Default, ResolveOptions.Default)); } diff --git a/src/NzbDrone.Core/Datastore/Migration/149_convert_regex_required_tags.cs b/src/NzbDrone.Core/Datastore/Migration/149_convert_regex_required_tags.cs index 18ba36813..436ce949f 100644 --- a/src/NzbDrone.Core/Datastore/Migration/149_convert_regex_required_tags.cs +++ b/src/NzbDrone.Core/Datastore/Migration/149_convert_regex_required_tags.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Data; using System.Linq; using System.Text.RegularExpressions; @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Datastore.Migration modifiers += "RQ"; } - if (modifiers != "") + if (!string.IsNullOrEmpty(modifiers)) { modifiers = "_" + modifiers; } diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index 660382c47..781fc414c 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -305,7 +305,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc var metadataFileName = GetMovieMetadataFilename(movieFile.RelativePath); - return xmlResult == string.Empty ? null : new MetadataFileResult(metadataFileName, xmlResult.Trim(Environment.NewLine.ToCharArray())); + return string.IsNullOrEmpty(xmlResult) ? null : new MetadataFileResult(metadataFileName, xmlResult.Trim(Environment.NewLine.ToCharArray())); } public override List MovieImages(Movie movie) diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs index 04a0dc313..f24199d67 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs @@ -348,7 +348,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo return ""; // Other } - if (videoCodecLibrary == "") + if (string.IsNullOrEmpty(videoCodecLibrary)) { return ""; // Unknown mp4v } diff --git a/src/NzbDrone.Core/Parser/IsoLanguages.cs b/src/NzbDrone.Core/Parser/IsoLanguages.cs index 18657bb8a..94d178be1 100644 --- a/src/NzbDrone.Core/Parser/IsoLanguages.cs +++ b/src/NzbDrone.Core/Parser/IsoLanguages.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Parser if (isoArray.Length > 1) { isoLanguages = isoLanguages.Any(l => l.CountryCode == isoArray[1].ToLower()) ? - isoLanguages.Where(l => l.CountryCode == isoArray[1].ToLower()).ToList() : isoLanguages.Where(l => l.CountryCode == "").ToList(); + isoLanguages.Where(l => l.CountryCode == isoArray[1].ToLower()).ToList() : isoLanguages.Where(l => string.IsNullOrEmpty(l.CountryCode)).ToList(); } return isoLanguages.FirstOrDefault(); diff --git a/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs b/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs index a190fc1ce..a837b59a6 100644 --- a/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs +++ b/src/NzbDrone.Mono/Disk/SymbolicLinkResolver.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Mono.Disk var target = 0; for (var i = 0; i < dirs.Length; ++i) { - if (dirs[i] == "." || dirs[i] == string.Empty) + if (dirs[i] == "." || string.IsNullOrEmpty(dirs[i])) { continue; }