mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-16 05:43:54 +03:00
[PR #4265] [MERGED] Remove unnecessary null checks in some places #9985
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/jellyfin/jellyfin/pull/4265
Author: @KonH
Created: 10/3/2020
Status: ✅ Merged
Merged: 10/6/2020
Merged by: @dkanada
Base:
master← Head:remove_unnecessary_null_checks📝 Commits (1)
211c9cdRemove unnecessary null checks in some places📊 Changes
3 files changed (+3 additions, -6 deletions)
View changed files
📝
Jellyfin.Api/Helpers/MediaInfoHelper.cs(+1 -1)📝
Jellyfin.Api/Helpers/TranscodingJobHelper.cs(+1 -4)📝
Jellyfin.Server.Implementations/Users/UserManager.cs(+1 -1)📄 Description
Hello!
I made a small PR to understand how that approach fits the project.
Now nullable data types are used widely inside the project, but it leads to warnings, which can be resolved (obviously, we cannot fix it in public methods, because have no guarantees about its usage, but can inspect private methods properly).
Changes
GetPasswordResetProviders is called from StartForgotPasswordProcess only and that place already check user against null, so conditional access is not required
OnFfMpegProcessExited is called only from StartFfMpeg, where it created from OnTranscodeBeginning, which guaranteed that it is not null, so conditional access here is not required
GetMaxBitrate is called from two places, but if code passed to it, the user variable cannot be null (if it is not true, NullReferenceException already be thrown)
Issues
Related to https://github.com/jellyfin/jellyfin/issues/2149
Do you think it's a working approach for other areas of the project?
Can it help you with maintaining it?
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.