mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Use pattern matching for null checks (#13793)
Fix the few that slipped through
This commit is contained in:
parent
3fc3b04daf
commit
e9729a536f
@ -1753,7 +1753,7 @@ public class DynamicHlsController : BaseJellyfinApiController
|
|||||||
|
|
||||||
if (channels.HasValue
|
if (channels.HasValue
|
||||||
&& (channels.Value != 2
|
&& (channels.Value != 2
|
||||||
|| (state.AudioStream?.Channels != null && !useDownMixAlgorithm)))
|
|| (state.AudioStream?.Channels is not null && !useDownMixAlgorithm)))
|
||||||
{
|
{
|
||||||
args += " -ac " + channels.Value;
|
args += " -ac " + channels.Value;
|
||||||
}
|
}
|
||||||
|
@ -5621,7 +5621,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
var doDeintH2645 = doDeintH264 || doDeintHevc;
|
var doDeintH2645 = doDeintH264 || doDeintHevc;
|
||||||
var doOclTonemap = IsHwTonemapAvailable(state, options);
|
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 hasTextSubs = hasSubs && state.SubtitleStream.IsTextSubtitleStream;
|
||||||
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
|
var hasGraphicalSubs = hasSubs && !state.SubtitleStream.IsTextSubtitleStream;
|
||||||
var hasAssSubs = hasSubs
|
var hasAssSubs = hasSubs
|
||||||
|
@ -21,7 +21,7 @@ public static class ContainerHelper
|
|||||||
public static bool ContainsContainer(string? profileContainers, string? inputContainer)
|
public static bool ContainsContainer(string? profileContainers, string? inputContainer)
|
||||||
{
|
{
|
||||||
var isNegativeList = false;
|
var isNegativeList = false;
|
||||||
if (profileContainers != null && profileContainers.StartsWith('-'))
|
if (profileContainers is not null && profileContainers.StartsWith('-'))
|
||||||
{
|
{
|
||||||
isNegativeList = true;
|
isNegativeList = true;
|
||||||
profileContainers = profileContainers[1..];
|
profileContainers = profileContainers[1..];
|
||||||
@ -42,7 +42,7 @@ public static class ContainerHelper
|
|||||||
public static bool ContainsContainer(string? profileContainers, ReadOnlySpan<char> inputContainer)
|
public static bool ContainsContainer(string? profileContainers, ReadOnlySpan<char> inputContainer)
|
||||||
{
|
{
|
||||||
var isNegativeList = false;
|
var isNegativeList = false;
|
||||||
if (profileContainers != null && profileContainers.StartsWith('-'))
|
if (profileContainers is not null && profileContainers.StartsWith('-'))
|
||||||
{
|
{
|
||||||
isNegativeList = true;
|
isNegativeList = true;
|
||||||
profileContainers = profileContainers[1..];
|
profileContainers = profileContainers[1..];
|
||||||
|
@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
foreach (var season in seasons)
|
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)
|
if (hasUpdate)
|
||||||
{
|
{
|
||||||
await season.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
await season.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
||||||
|
@ -95,7 +95,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||||||
originalTitle.Append(" / ").Append(additionalEpisode.Item.OriginalTitle);
|
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);
|
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)
|
protected static string SortNameOrName(BaseItem item)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.SortName != null)
|
if (item.SortName is not null)
|
||||||
{
|
{
|
||||||
string trimmed = item.SortName.Trim();
|
string trimmed = item.SortName.Trim();
|
||||||
if (trimmed.Length > 0)
|
if (trimmed.Length > 0)
|
||||||
|
@ -87,7 +87,7 @@ public class UserControllerTests
|
|||||||
Assert.Contains(
|
Assert.Contains(
|
||||||
Validate(userPolicy), v =>
|
Validate(userPolicy), v =>
|
||||||
v.MemberNames.Contains("PasswordResetProviderId") &&
|
v.MemberNames.Contains("PasswordResetProviderId") &&
|
||||||
v.ErrorMessage != null &&
|
v.ErrorMessage is not null &&
|
||||||
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
|
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class UserControllerTests
|
|||||||
|
|
||||||
Assert.Contains(Validate(userPolicy), v =>
|
Assert.Contains(Validate(userPolicy), v =>
|
||||||
v.MemberNames.Contains("AuthenticationProviderId") &&
|
v.MemberNames.Contains("AuthenticationProviderId") &&
|
||||||
v.ErrorMessage != null &&
|
v.ErrorMessage is not null &&
|
||||||
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
|
v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class StreamInfoTests
|
|||||||
/// <returns>An <see cref="Array"/> of <see cref="Type"/>.</returns>
|
/// <returns>An <see cref="Array"/> of <see cref="Type"/>.</returns>
|
||||||
private static object? RandomArray(Random random, Type? elementType)
|
private static object? RandomArray(Random random, Type? elementType)
|
||||||
{
|
{
|
||||||
if (elementType == null)
|
if (elementType is null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public class StreamInfoTests
|
|||||||
|
|
||||||
var type = property.PropertyType;
|
var type = property.PropertyType;
|
||||||
// If nullable, then set it to null, 25% of the time.
|
// 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)
|
if (random.Next(0, 4) == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user