[PR #4265] [MERGED] Remove unnecessary null checks in some places #9985

Closed
opened 2026-02-07 06:12:03 +03:00 by OVERLORD · 0 comments
Owner

📋 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: masterHead: remove_unnecessary_null_checks


📝 Commits (1)

  • 211c9cd Remove 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

  1. GetPasswordResetProviders is called from StartForgotPasswordProcess only and that place already check user against null, so conditional access is not required

  2. 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

  3. 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.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/4265 **Author:** [@KonH](https://github.com/KonH) **Created:** 10/3/2020 **Status:** ✅ Merged **Merged:** 10/6/2020 **Merged by:** [@dkanada](https://github.com/dkanada) **Base:** `master` ← **Head:** `remove_unnecessary_null_checks` --- ### 📝 Commits (1) - [`211c9cd`](https://github.com/jellyfin/jellyfin/commit/211c9cd60850c6c33d1211cc5a7e35a94b19bab4) Remove unnecessary null checks in some places ### 📊 Changes **3 files changed** (+3 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `Jellyfin.Api/Helpers/MediaInfoHelper.cs` (+1 -1) 📝 `Jellyfin.Api/Helpers/TranscodingJobHelper.cs` (+1 -4) 📝 `Jellyfin.Server.Implementations/Users/UserManager.cs` (+1 -1) </details> ### 📄 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** 1) GetPasswordResetProviders is called from StartForgotPasswordProcess only and that place already check user against null, so conditional access is not required 2) 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 3) 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) <!-- Describe your changes here in 1-5 sentences. --> **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? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 06:12:03 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#9985