Use pattern matching for null checks (#13793)

Fix the few that slipped through
master
Bond-009 2 weeks ago committed by GitHub
parent 3fc3b04daf
commit e9729a536f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1753,7 +1753,7 @@ public class DynamicHlsController : BaseJellyfinApiController
if (channels.HasValue
&& (channels.Value != 2
|| (state.AudioStream?.Channels != null && !useDownMixAlgorithm)))
|| (state.AudioStream?.Channels is not null && !useDownMixAlgorithm)))
{
args += " -ac " + channels.Value;
}

@ -5621,7 +5621,7 @@ namespace MediaBrowser.Controller.MediaEncoding
var doDeintH2645 = doDeintH264 || doDeintHevc;
var doOclTonemap = IsHwTonemapAvailable(state, options);
var hasSubs = state.SubtitleStream != null && ShouldEncodeSubtitle(state);
var hasSubs = state.SubtitleStream is not null && ShouldEncodeSubtitle(state);
var hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
var hasAssSubs = hasSubs

@ -21,7 +21,7 @@ public static class ContainerHelper
public static bool ContainsContainer(string? profileContainers, string? inputContainer)
{
var isNegativeList = false;
if (profileContainers != null && profileContainers.StartsWith('-'))
if (profileContainers is not null && profileContainers.StartsWith('-'))
{
isNegativeList = true;
profileContainers = profileContainers[1..];
@ -42,7 +42,7 @@ public static class ContainerHelper
public static bool ContainsContainer(string? profileContainers, ReadOnlySpan<char> inputContainer)
{
var isNegativeList = false;
if (profileContainers != null && profileContainers.StartsWith('-'))
if (profileContainers is not null && profileContainers.StartsWith('-'))
{
isNegativeList = true;
profileContainers = profileContainers[1..];

@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.TV
foreach (var season in seasons)
{
var hasUpdate = refreshOptions != null && season.BeforeMetadataRefresh(refreshOptions.ReplaceAllMetadata);
var hasUpdate = refreshOptions is not null && season.BeforeMetadataRefresh(refreshOptions.ReplaceAllMetadata);
if (hasUpdate)
{
await season.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);

@ -95,7 +95,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
originalTitle.Append(" / ").Append(additionalEpisode.Item.OriginalTitle);
}
if (additionalEpisode.Item.IndexNumber != null)
if (additionalEpisode.Item.IndexNumber is not null)
{
item.Item.IndexNumberEnd = Math.Max((int)additionalEpisode.Item.IndexNumber, item.Item.IndexNumberEnd ?? (int)additionalEpisode.Item.IndexNumber);
}

@ -1020,12 +1020,12 @@ namespace MediaBrowser.XbmcMetadata.Savers
protected static string SortNameOrName(BaseItem item)
{
if (item == null)
if (item is null)
{
return string.Empty;
}
if (item.SortName != null)
if (item.SortName is not null)
{
string trimmed = item.SortName.Trim();
if (trimmed.Length > 0)

@ -87,7 +87,7 @@ public class UserControllerTests
Assert.Contains(
Validate(userPolicy), v =>
v.MemberNames.Contains("PasswordResetProviderId") &&
v.ErrorMessage != null &&
v.ErrorMessage is not null &&
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
}
@ -105,7 +105,7 @@ public class UserControllerTests
Assert.Contains(Validate(userPolicy), v =>
v.MemberNames.Contains("AuthenticationProviderId") &&
v.ErrorMessage != null &&
v.ErrorMessage is not null &&
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
}

@ -31,7 +31,7 @@ public class StreamInfoTests
/// <returns>An <see cref="Array"/> of <see cref="Type"/>.</returns>
private static object? RandomArray(Random random, Type? elementType)
{
if (elementType == null)
if (elementType is null)
{
return null;
}
@ -148,7 +148,7 @@ public class StreamInfoTests
var type = property.PropertyType;
// If nullable, then set it to null, 25% of the time.
if (Nullable.GetUnderlyingType(type) != null)
if (Nullable.GetUnderlyingType(type) is not null)
{
if (random.Next(0, 4) == 0)
{

Loading…
Cancel
Save