Skip to content

Commit

Permalink
Use 'not null' pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
jnm2 committed Aug 12, 2023
1 parent 81a056f commit 6f0b108
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/YouTubeDownloadTool/AvailableToolDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<Stream> DownloadAsync(CancellationToken cancellationToken)

var stream = await response.Content.ReadAsStreamAsync(cancellationToken);

return streamTransform is { }
return streamTransform is not null
? streamTransform.Invoke(stream)
: stream;
}
Expand Down
2 changes: 1 addition & 1 deletion src/YouTubeDownloadTool/DownloadResolvers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static Func<CancellationToken, Task<AvailableToolDownload>> GitHubRelease

var version = document.RootElement.GetProperty("tag_name").GetString()!;

if (assetName is { })
if (assetName is not null)
{
foreach (var asset in document.RootElement.GetProperty("assets").EnumerateArray())
{
Expand Down
2 changes: 1 addition & 1 deletion src/YouTubeDownloadTool/ToolResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private async Task<LeaseSource> ResolveLatestToolAsync()
{
using var download = await getLatestDownloadAsync.Invoke(CancellationToken.None).ConfigureAwait(false);

if (currentSource is { } && string.Equals(download.Version, currentSource.Version, StringComparison.OrdinalIgnoreCase))
if (currentSource is not null && string.Equals(download.Version, currentSource.Version, StringComparison.OrdinalIgnoreCase))
return currentSource;

var fileLock = await Utils.GetOrDownloadFileAsync(
Expand Down
2 changes: 1 addition & 1 deletion src/YouTubeDownloadTool/Utils/TaskDeduplicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Task<T> StartOrJoin()
lastSeenTask = Interlocked.CompareExchange(ref currentTask, source.Task, taskToReplace);
if (lastSeenTask == taskToReplace) break;

if (lastSeenTask is { })
if (lastSeenTask is not null)
{
// Return even if the new task is complete because it’s so close to having both just started and
// just finished that it’s just as good. There’s no way to avoid returning a task that was not
Expand Down

0 comments on commit 6f0b108

Please sign in to comment.