Преглед изворни кода

Merge pull request #9607 from goremykin/fix_analyzers_warnings_and_suggestions

Bond-009 пре 2 година
родитељ
комит
15c8854502
64 измењених фајлова са 238 додато и 300 уклоњено
  1. 0 1
      Emby.Dlna/Main/DlnaEntryPoint.cs
  2. 6 6
      Emby.Dlna/PlayTo/TransportCommands.cs
  3. 1 1
      Emby.Server.Implementations/Data/BaseSqliteRepository.cs
  4. 28 14
      Emby.Server.Implementations/Data/SqliteItemRepository.cs
  5. 1 4
      Emby.Server.Implementations/Dto/DtoService.cs
  6. 1 3
      Emby.Server.Implementations/Library/LibraryManager.cs
  7. 2 2
      Emby.Server.Implementations/Library/MediaSourceManager.cs
  8. 2 1
      Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
  9. 3 6
      Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
  10. 4 5
      Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
  11. 1 1
      Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
  12. 1 2
      Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
  13. 6 6
      Emby.Server.Implementations/Localization/LocalizationManager.cs
  14. 2 2
      Emby.Server.Implementations/Session/SessionManager.cs
  15. 4 8
      Emby.Server.Implementations/SyncPlay/Group.cs
  16. 2 4
      Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
  17. 0 1
      Jellyfin.Api/Controllers/FilterController.cs
  18. 0 2
      Jellyfin.Api/Controllers/QuickConnectController.cs
  19. 0 1
      Jellyfin.Api/Controllers/SearchController.cs
  20. 2 4
      Jellyfin.Api/Controllers/SubtitleController.cs
  21. 0 1
      Jellyfin.Api/Controllers/UniversalAudioController.cs
  22. 6 6
      Jellyfin.Networking/Manager/NetworkManager.cs
  23. 0 1
      Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
  24. 0 1
      Jellyfin.Server/CoreAppHost.cs
  25. 1 3
      Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs
  26. 0 1
      Jellyfin.Server/Startup.cs
  27. 1 1
      MediaBrowser.Common/Plugins/BasePluginOfT.cs
  28. 6 8
      MediaBrowser.Controller/Entities/BaseItem.cs
  29. 2 4
      MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
  30. 0 2
      MediaBrowser.Controller/Lyrics/LyricMetadata.cs
  31. 71 75
      MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
  32. 0 1
      MediaBrowser.Controller/Session/ISessionManager.cs
  33. 0 1
      MediaBrowser.Controller/Subtitles/ISubtitleManager.cs
  34. 3 5
      MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs
  35. 11 18
      MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs
  36. 1 4
      MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
  37. 1 1
      MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
  38. 4 8
      MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
  39. 1 2
      MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs
  40. 4 4
      MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs
  41. 3 5
      MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
  42. 0 1
      MediaBrowser.Model/Configuration/ServerConfiguration.cs
  43. 2 1
      MediaBrowser.Model/Cryptography/PasswordHash.cs
  44. 16 8
      MediaBrowser.Model/Dlna/StreamBuilder.cs
  45. 1 1
      MediaBrowser.Model/Dlna/StreamInfo.cs
  46. 4 2
      MediaBrowser.Model/MediaInfo/AudioCodec.cs
  47. 0 1
      MediaBrowser.Providers/Lyric/TxtLyricProvider.cs
  48. 1 4
      MediaBrowser.Providers/Manager/MetadataService.cs
  49. 1 4
      MediaBrowser.Providers/Manager/ProviderManager.cs
  50. 1 4
      MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs
  51. 2 4
      RSSDP/HttpParserBase.cs
  52. 1 2
      RSSDP/HttpRequestParser.cs
  53. 1 2
      RSSDP/HttpResponseParser.cs
  54. 2 4
      RSSDP/SsdpDevice.cs
  55. 4 8
      RSSDP/SsdpDeviceLocator.cs
  56. 5 9
      RSSDP/SsdpDevicePublisher.cs
  57. 10 5
      src/Jellyfin.Extensions/AlphanumericComparator.cs
  58. 0 1
      src/Jellyfin.Extensions/Json/Converters/JsonBoolStringConverter.cs
  59. 0 2
      src/Jellyfin.Extensions/StringExtensions.cs
  60. 0 1
      tests/Jellyfin.Api.Tests/Auth/FirstTimeSetupPolicy/FirstTimeSetupHandlerTests.cs
  61. 0 1
      tests/Jellyfin.Api.Tests/Controllers/ImageControllerTests.cs
  62. 3 3
      tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs
  63. 2 5
      tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs
  64. 1 1
      tests/Jellyfin.XbmcMetadata.Tests/Parsers/SeriesNfoParserTests.cs

+ 0 - 1
Emby.Dlna/Main/DlnaEntryPoint.cs

@@ -7,7 +7,6 @@ using System.Globalization;
 using System.Linq;
 using System.Net.Http;
 using System.Net.Sockets;
-using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 using Emby.Dlna.PlayTo;
 using Emby.Dlna.Ssdp;

+ 6 - 6
Emby.Dlna/PlayTo/TransportCommands.cs

@@ -116,7 +116,7 @@ namespace Emby.Dlna.PlayTo
             return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamespace, stateString);
         }
 
-        public string BuildPost(ServiceAction action, string xmlNamesapce, object value, string commandParameter = "")
+        public string BuildPost(ServiceAction action, string xmlNamespace, object value, string commandParameter = "")
         {
             var stateString = string.Empty;
 
@@ -137,10 +137,10 @@ namespace Emby.Dlna.PlayTo
                 }
             }
 
-            return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamesapce, stateString);
+            return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamespace, stateString);
         }
 
-        public string BuildPost(ServiceAction action, string xmlNamesapce, object value, Dictionary<string, string> dictionary)
+        public string BuildPost(ServiceAction action, string xmlNamespace, object value, Dictionary<string, string> dictionary)
         {
             var stateString = string.Empty;
 
@@ -150,9 +150,9 @@ namespace Emby.Dlna.PlayTo
                 {
                     stateString += BuildArgumentXml(arg, "0");
                 }
-                else if (dictionary.ContainsKey(arg.Name))
+                else if (dictionary.TryGetValue(arg.Name, out var argValue))
                 {
-                    stateString += BuildArgumentXml(arg, dictionary[arg.Name]);
+                    stateString += BuildArgumentXml(arg, argValue);
                 }
                 else
                 {
@@ -160,7 +160,7 @@ namespace Emby.Dlna.PlayTo
                 }
             }
 
-            return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamesapce, stateString);
+            return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamespace, stateString);
         }
 
         private string BuildArgumentXml(Argument argument, string? value, string commandParameter = "")

+ 1 - 1
Emby.Server.Implementations/Data/BaseSqliteRepository.cs

@@ -139,7 +139,7 @@ namespace Emby.Server.Implementations.Data
 
             if (JournalSizeLimit.HasValue)
             {
-                WriteConnection.Execute("PRAGMA journal_size_limit=" + (int)JournalSizeLimit.Value);
+                WriteConnection.Execute("PRAGMA journal_size_limit=" + JournalSizeLimit.Value);
             }
 
             if (Synchronous.HasValue)

+ 28 - 14
Emby.Server.Implementations/Data/SqliteItemRepository.cs

@@ -1309,7 +1309,8 @@ namespace Emby.Server.Implementations.Data
                 {
                     return false;
                 }
-                else if (type == typeof(UserRootFolder))
+
+                if (type == typeof(UserRootFolder))
                 {
                     return false;
                 }
@@ -1319,55 +1320,68 @@ namespace Emby.Server.Implementations.Data
             {
                 return false;
             }
-            else if (type == typeof(MusicArtist))
+
+            if (type == typeof(MusicArtist))
             {
                 return false;
             }
-            else if (type == typeof(Person))
+
+            if (type == typeof(Person))
             {
                 return false;
             }
-            else if (type == typeof(MusicGenre))
+
+            if (type == typeof(MusicGenre))
             {
                 return false;
             }
-            else if (type == typeof(Genre))
+
+            if (type == typeof(Genre))
             {
                 return false;
             }
-            else if (type == typeof(Studio))
+
+            if (type == typeof(Studio))
             {
                 return false;
             }
-            else if (type == typeof(PlaylistsFolder))
+
+            if (type == typeof(PlaylistsFolder))
             {
                 return false;
             }
-            else if (type == typeof(PhotoAlbum))
+
+            if (type == typeof(PhotoAlbum))
             {
                 return false;
             }
-            else if (type == typeof(Year))
+
+            if (type == typeof(Year))
             {
                 return false;
             }
-            else if (type == typeof(Book))
+
+            if (type == typeof(Book))
             {
                 return false;
             }
-            else if (type == typeof(LiveTvProgram))
+
+            if (type == typeof(LiveTvProgram))
             {
                 return false;
             }
-            else if (type == typeof(AudioBook))
+
+            if (type == typeof(AudioBook))
             {
                 return false;
             }
-            else if (type == typeof(Audio))
+
+            if (type == typeof(Audio))
             {
                 return false;
             }
-            else if (type == typeof(MusicAlbum))
+
+            if (type == typeof(MusicAlbum))
             {
                 return false;
             }

+ 1 - 4
Emby.Server.Implementations/Dto/DtoService.cs

@@ -7,7 +7,6 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.IO;
 using System.Linq;
-using Jellyfin.Api.Helpers;
 using Jellyfin.Data.Entities;
 using Jellyfin.Data.Enums;
 using Jellyfin.Extensions;
@@ -572,9 +571,7 @@ namespace Emby.Server.Implementations.Dto
                         return null;
                     }
                 }).Where(i => i is not null)
-                .Where(i => user is null ?
-                    true :
-                    i.IsVisible(user))
+                .Where(i => user is null || i.IsVisible(user))
                 .DistinctBy(x => x.Name, StringComparer.OrdinalIgnoreCase)
                 .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
 

+ 1 - 3
Emby.Server.Implementations/Library/LibraryManager.cs

@@ -2749,9 +2749,7 @@ namespace Emby.Server.Implementations.Library
                 }
             })
             .Where(i => i is not null)
-            .Where(i => query.User is null ?
-                true :
-                i.IsVisible(query.User))
+            .Where(i => query.User is null || i.IsVisible(query.User))
             .ToList();
         }
 

+ 2 - 2
Emby.Server.Implementations/Library/MediaSourceManager.cs

@@ -154,8 +154,8 @@ namespace Emby.Server.Implementations.Library
             // If file is strm or main media stream is missing, force a metadata refresh with remote probing
             if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder
                 && (item.Path.EndsWith(".strm", StringComparison.OrdinalIgnoreCase)
-                    || (item.MediaType == MediaType.Video && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Video))
-                    || (item.MediaType == MediaType.Audio && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio))))
+                    || (item.MediaType == MediaType.Video && mediaSources[0].MediaStreams.All(i => i.Type != MediaStreamType.Video))
+                    || (item.MediaType == MediaType.Audio && mediaSources[0].MediaStreams.All(i => i.Type != MediaStreamType.Audio))))
             {
                 await item.RefreshMetadata(
                     new MetadataRefreshOptions(_directoryService)

+ 2 - 1
Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs

@@ -78,7 +78,8 @@ namespace Emby.Server.Implementations.Library.Resolvers
                             Set3DFormat(videoTmp);
                             return videoTmp;
                         }
-                        else if (IsBluRayDirectory(filename))
+
+                        if (IsBluRayDirectory(filename))
                         {
                             var videoTmp = new TVideoType
                             {

+ 3 - 6
Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs

@@ -627,10 +627,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
                     _timerProvider.Update(existingTimer);
                     return Task.FromResult(existingTimer.Id);
                 }
-                else
-                {
-                    throw new ArgumentException("A scheduled recording already exists for this program.");
-                }
+
+                throw new ArgumentException("A scheduled recording already exists for this program.");
             }
 
             info.Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
@@ -1866,8 +1864,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
                 {
                     await writer.WriteStartDocumentAsync(true).ConfigureAwait(false);
                     await writer.WriteStartElementAsync(null, "tvshow", null).ConfigureAwait(false);
-                    string id;
-                    if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(), out id))
+                    if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(), out var id))
                     {
                         await writer.WriteElementStringAsync(null, "id", null, id).ConfigureAwait(false);
                     }

+ 4 - 5
Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs

@@ -415,14 +415,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
             {
                 return null;
             }
-            else if (uri.IndexOf("http", StringComparison.OrdinalIgnoreCase) != -1)
+
+            if (uri.IndexOf("http", StringComparison.OrdinalIgnoreCase) != -1)
             {
                 return uri;
             }
-            else
-            {
-                return apiUrl + "/image/" + uri + "?token=" + token;
-            }
+
+            return apiUrl + "/image/" + uri + "?token=" + token;
         }
 
         private static double GetAspectRatio(ImageDataDto i)

+ 1 - 1
Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs

@@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
         public async Task<bool> CheckTunerAvailability(IPAddress remoteIp, int tuner, CancellationToken cancellationToken)
         {
             using var client = new TcpClient();
-            await client.ConnectAsync(remoteIp, HdHomeRunPort).ConfigureAwait(false);
+            await client.ConnectAsync(remoteIp, HdHomeRunPort, cancellationToken).ConfigureAwait(false);
 
             using var stream = client.GetStream();
             return await CheckTunerAvailability(stream, tuner, cancellationToken).ConfigureAwait(false);

+ 1 - 2
Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs

@@ -170,9 +170,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
             var nameInExtInf = nameParts.Length > 1 ? nameParts[^1].AsSpan().Trim() : ReadOnlySpan<char>.Empty;
 
             string numberString = null;
-            string attributeValue;
 
-            if (attributes.TryGetValue("tvg-chno", out attributeValue)
+            if (attributes.TryGetValue("tvg-chno", out var attributeValue)
                 && double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
             {
                 numberString = attributeValue;

+ 6 - 6
Emby.Server.Implementations/Localization/LocalizationManager.cs

@@ -198,25 +198,25 @@ namespace Emby.Server.Implementations.Localization
             }
 
             // Minimum rating possible
-            if (!ratings.Any(x => x.Value == 0))
+            if (ratings.All(x => x.Value != 0))
             {
                 ratings.Add(new ParentalRating("Approved", 0));
             }
 
             // Matches PG (this has different age restrictions depending on country)
-            if (!ratings.Any(x => x.Value == 10))
+            if (ratings.All(x => x.Value != 10))
             {
                 ratings.Add(new ParentalRating("10", 10));
             }
 
             // Matches PG-13
-            if (!ratings.Any(x => x.Value == 13))
+            if (ratings.All(x => x.Value != 13))
             {
                 ratings.Add(new ParentalRating("13", 13));
             }
 
             // Matches TV-14
-            if (!ratings.Any(x => x.Value == 14))
+            if (ratings.All(x => x.Value != 14))
             {
                 ratings.Add(new ParentalRating("14", 14));
             }
@@ -229,13 +229,13 @@ namespace Emby.Server.Implementations.Localization
             }
 
             // A lot of countries don't excplicitly have a seperate rating for adult content
-            if (!ratings.Any(x => x.Value == 1000))
+            if (ratings.All(x => x.Value != 1000))
             {
                 ratings.Add(new ParentalRating("XXX", 1000));
             }
 
             // A lot of countries don't excplicitly have a seperate rating for banned content
-            if (!ratings.Any(x => x.Value == 1001))
+            if (ratings.All(x => x.Value != 1001))
             {
                 ratings.Add(new ParentalRating("Banned", 1001));
             }

+ 2 - 2
Emby.Server.Implementations/Session/SessionManager.cs

@@ -606,7 +606,7 @@ namespace Emby.Server.Implementations.Session
                     }
                     catch (Exception ex)
                     {
-                        _logger.LogDebug("Error calling OnPlaybackStopped", ex);
+                        _logger.LogDebug(ex, "Error calling OnPlaybackStopped");
                     }
                 }
 
@@ -953,7 +953,7 @@ namespace Emby.Server.Implementations.Session
                 }
                 catch (Exception ex)
                 {
-                    _logger.LogError("Error closing live stream", ex);
+                    _logger.LogError(ex, "Error closing live stream");
                 }
             }
 

+ 4 - 8
Emby.Server.Implementations/SyncPlay/Group.cs

@@ -620,10 +620,8 @@ namespace Emby.Server.Implementations.SyncPlay
                 RestartCurrentItem();
                 return true;
             }
-            else
-            {
-                return false;
-            }
+
+            return false;
         }
 
         /// <inheritdoc />
@@ -637,10 +635,8 @@ namespace Emby.Server.Implementations.SyncPlay
                 RestartCurrentItem();
                 return true;
             }
-            else
-            {
-                return false;
-            }
+
+            return false;
         }
 
         /// <inheritdoc />

+ 2 - 4
Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs

@@ -339,10 +339,8 @@ namespace Emby.Server.Implementations.SyncPlay
             {
                 return sessionsCounter > 0;
             }
-            else
-            {
-                return false;
-            }
+
+            return false;
         }
 
         /// <summary>

+ 0 - 1
Jellyfin.Api/Controllers/FilterController.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Linq;
-using Jellyfin.Api.Constants;
 using Jellyfin.Api.Helpers;
 using Jellyfin.Api.ModelBinders;
 using Jellyfin.Data.Enums;

+ 0 - 2
Jellyfin.Api/Controllers/QuickConnectController.cs

@@ -1,8 +1,6 @@
 using System;
 using System.ComponentModel.DataAnnotations;
 using System.Threading.Tasks;
-using Jellyfin.Api.Constants;
-using Jellyfin.Api.Extensions;
 using Jellyfin.Api.Helpers;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Controller.Authentication;

+ 0 - 1
Jellyfin.Api/Controllers/SearchController.cs

@@ -3,7 +3,6 @@ using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
 using System.Globalization;
 using System.Linq;
-using Jellyfin.Api.Constants;
 using Jellyfin.Api.Helpers;
 using Jellyfin.Api.ModelBinders;
 using Jellyfin.Data.Enums;

+ 2 - 4
Jellyfin.Api/Controllers/SubtitleController.cs

@@ -533,10 +533,8 @@ public class SubtitleController : BaseJellyfinApiController
                 _logger.LogDebug("Fallback font size is {FileSize} Bytes", fileSize);
                 return PhysicalFile(fontFile.FullName, MimeTypes.GetMimeType(fontFile.FullName));
             }
-            else
-            {
-                _logger.LogWarning("The selected font is null or empty");
-            }
+
+            _logger.LogWarning("The selected font is null or empty");
         }
         else
         {

+ 0 - 1
Jellyfin.Api/Controllers/UniversalAudioController.cs

@@ -5,7 +5,6 @@ using System.Globalization;
 using System.Linq;
 using System.Threading.Tasks;
 using Jellyfin.Api.Attributes;
-using Jellyfin.Api.Extensions;
 using Jellyfin.Api.Helpers;
 using Jellyfin.Api.ModelBinders;
 using Jellyfin.Api.Models.StreamingDtos;

+ 6 - 6
Jellyfin.Networking/Manager/NetworkManager.cs

@@ -500,10 +500,8 @@ namespace Jellyfin.Networking.Manager
             {
                 return true;
             }
-            else
-            {
-                return address.IsPrivateAddressRange();
-            }
+
+            return address.IsPrivateAddressRange();
         }
 
         /// <inheritdoc/>
@@ -1171,13 +1169,15 @@ namespace Jellyfin.Networking.Manager
                     bindPreference = addr.Value;
                     break;
                 }
-                else if ((addr.Key.Address.Equals(IPAddress.Any) || addr.Key.Address.Equals(IPAddress.IPv6Any)) && isInExternalSubnet)
+
+                if ((addr.Key.Address.Equals(IPAddress.Any) || addr.Key.Address.Equals(IPAddress.IPv6Any)) && isInExternalSubnet)
                 {
                     // External.
                     bindPreference = addr.Value;
                     break;
                 }
-                else if (addr.Key.Contains(source))
+
+                if (addr.Key.Contains(source))
                 {
                     // Match ip address.
                     bindPreference = addr.Value;

+ 0 - 1
Jellyfin.Server.Implementations/Security/AuthorizationContext.cs

@@ -4,7 +4,6 @@ using System;
 using System.Collections.Generic;
 using System.Net;
 using System.Threading.Tasks;
-using EFCoreSecondLevelCacheInterceptor;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Net;

+ 0 - 1
Jellyfin.Server/CoreAppHost.cs

@@ -22,7 +22,6 @@ using MediaBrowser.Controller.Lyrics;
 using MediaBrowser.Controller.Net;
 using MediaBrowser.Controller.Security;
 using MediaBrowser.Model.Activity;
-using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Logging;

+ 1 - 3
Jellyfin.Server/Migrations/Routines/MigrateDisplayPreferencesDb.cs

@@ -133,9 +133,7 @@ namespace Jellyfin.Server.Migrations.Routines
                         SkipBackwardLength = dto.CustomPrefs.TryGetValue("skipBackLength", out length) && int.TryParse(length, out var skipBackwardLength)
                             ? skipBackwardLength
                             : 10000,
-                        EnableNextVideoInfoOverlay = dto.CustomPrefs.TryGetValue("enableNextVideoInfoOverlay", out var enabled) && !string.IsNullOrEmpty(enabled)
-                            ? bool.Parse(enabled)
-                            : true,
+                        EnableNextVideoInfoOverlay = !dto.CustomPrefs.TryGetValue("enableNextVideoInfoOverlay", out var enabled) || string.IsNullOrEmpty(enabled) || bool.Parse(enabled),
                         DashboardTheme = dto.CustomPrefs.TryGetValue("dashboardtheme", out var theme) ? theme : string.Empty,
                         TvHome = dto.CustomPrefs.TryGetValue("tvhome", out var home) ? home : string.Empty
                     };

+ 0 - 1
Jellyfin.Server/Startup.cs

@@ -4,7 +4,6 @@ using System.Net;
 using System.Net.Http;
 using System.Net.Http.Headers;
 using System.Net.Mime;
-using System.Runtime.InteropServices;
 using System.Text;
 using Jellyfin.Api.Middleware;
 using Jellyfin.MediaEncoding.Hls.Extensions;

+ 1 - 1
MediaBrowser.Common/Plugins/BasePluginOfT.cs

@@ -50,7 +50,7 @@ namespace MediaBrowser.Common.Plugins
             if (Version is not null && !Directory.Exists(dataFolderPath))
             {
                 // Try again with the version number appended to the folder name.
-                dataFolderPath += "_" + Version.ToString();
+                dataFolderPath += "_" + Version;
             }
 
             SetAttributes(assemblyFilePath, dataFolderPath, assemblyName.Version);

+ 6 - 8
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -801,16 +801,14 @@ namespace MediaBrowser.Controller.Entities
             {
                 return allowed.Contains(ChannelId);
             }
-            else
-            {
-                var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
 
-                foreach (var folder in collectionFolders)
+            var collectionFolders = LibraryManager.GetCollectionFolders(this, allCollectionFolders);
+
+            foreach (var folder in collectionFolders)
+            {
+                if (allowed.Contains(folder.Id))
                 {
-                    if (allowed.Contains(folder.Id))
-                    {
-                        return true;
-                    }
+                    return true;
                 }
             }
 

+ 2 - 4
MediaBrowser.Controller/LiveTv/LiveTvProgram.cs

@@ -197,10 +197,8 @@ namespace MediaBrowser.Controller.LiveTv
             {
                 return 2.0 / 3;
             }
-            else
-            {
-                return 16.0 / 9;
-            }
+
+            return 16.0 / 9;
         }
 
         public override string GetClientTypeName()

+ 0 - 2
MediaBrowser.Controller/Lyrics/LyricMetadata.cs

@@ -1,5 +1,3 @@
-using System;
-
 namespace MediaBrowser.Controller.Lyrics;
 
 /// <summary>

+ 71 - 75
MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

@@ -138,14 +138,10 @@ namespace MediaBrowser.Controller.MediaEncoding
 
                 if (!string.IsNullOrEmpty(hwType)
                     && encodingOptions.EnableHardwareEncoding
-                    && codecMap.ContainsKey(hwType))
+                    && codecMap.TryGetValue(hwType, out var preferredEncoder)
+                    && _mediaEncoder.SupportsEncoder(preferredEncoder))
                 {
-                    var preferredEncoder = codecMap[hwType];
-
-                    if (_mediaEncoder.SupportsEncoder(preferredEncoder))
-                    {
-                        return preferredEncoder;
-                    }
+                    return preferredEncoder;
                 }
             }
 
@@ -561,7 +557,8 @@ namespace MediaBrowser.Controller.MediaEncoding
             {
                 return Array.FindIndex(_videoProfilesH264, x => string.Equals(x, profile, StringComparison.OrdinalIgnoreCase));
             }
-            else if (string.Equals("hevc", videoCodec, StringComparison.OrdinalIgnoreCase))
+
+            if (string.Equals("hevc", videoCodec, StringComparison.OrdinalIgnoreCase))
             {
                 return Array.FindIndex(_videoProfilesH265, x => string.Equals(x, profile, StringComparison.OrdinalIgnoreCase));
             }
@@ -1113,19 +1110,19 @@ namespace MediaBrowser.Controller.MediaEncoding
             {
                 return "-bsf:v h264_mp4toannexb";
             }
-            else if (IsH265(stream))
+
+            if (IsH265(stream))
             {
                 return "-bsf:v hevc_mp4toannexb";
             }
-            else if (IsAAC(stream))
+
+            if (IsAAC(stream))
             {
                 // Convert adts header(mpegts) to asc header(mp4).
                 return "-bsf:a aac_adtstoasc";
             }
-            else
-            {
-                return null;
-            }
+
+            return null;
         }
 
         public static string GetAudioBitStreamArguments(EncodingJobInfo state, string segmentContainer, string mediaSourceContainer)
@@ -1203,10 +1200,8 @@ namespace MediaBrowser.Controller.MediaEncoding
                 {
                     return FormattableString.Invariant($" -rc_mode CBR -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
                 }
-                else
-                {
-                    return FormattableString.Invariant($" -rc_mode VBR -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
-                }
+
+                return FormattableString.Invariant($" -rc_mode VBR -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
             }
 
             return FormattableString.Invariant($" -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
@@ -2618,8 +2613,8 @@ namespace MediaBrowser.Controller.MediaEncoding
 
             if (outputWidth > maximumWidth || outputHeight > maximumHeight)
             {
-                var scaleW = (double)maximumWidth / (double)outputWidth;
-                var scaleH = (double)maximumHeight / (double)outputHeight;
+                var scaleW = (double)maximumWidth / outputWidth;
+                var scaleH = (double)maximumHeight / outputHeight;
                 var scale = Math.Min(scaleW, scaleH);
                 outputWidth = Math.Min(maximumWidth, (int)(outputWidth * scale));
                 outputHeight = Math.Min(maximumHeight, (int)(outputHeight * scale));
@@ -2766,79 +2761,76 @@ namespace MediaBrowser.Controller.MediaEncoding
                             widthParam,
                             heightParam);
                 }
-                else
-                {
-                    return GetFixedSwScaleFilter(threedFormat, requestedWidth.Value, requestedHeight.Value);
-                }
+
+                return GetFixedSwScaleFilter(threedFormat, requestedWidth.Value, requestedHeight.Value);
             }
 
             // If Max dimensions were supplied, for width selects lowest even number between input width and width req size and selects lowest even number from in width*display aspect and requested size
-            else if (requestedMaxWidth.HasValue && requestedMaxHeight.HasValue)
+
+            if (requestedMaxWidth.HasValue && requestedMaxHeight.HasValue)
             {
                 var maxWidthParam = requestedMaxWidth.Value.ToString(CultureInfo.InvariantCulture);
                 var maxHeightParam = requestedMaxHeight.Value.ToString(CultureInfo.InvariantCulture);
 
                 return string.Format(
-                        CultureInfo.InvariantCulture,
-                        "scale=trunc(min(max(iw\\,ih*a)\\,min({0}\\,{1}*a))/{2})*{2}:trunc(min(max(iw/a\\,ih)\\,min({0}/a\\,{1}))/2)*2",
-                        maxWidthParam,
-                        maxHeightParam,
-                        scaleVal);
+                    CultureInfo.InvariantCulture,
+                    "scale=trunc(min(max(iw\\,ih*a)\\,min({0}\\,{1}*a))/{2})*{2}:trunc(min(max(iw/a\\,ih)\\,min({0}/a\\,{1}))/2)*2",
+                    maxWidthParam,
+                    maxHeightParam,
+                    scaleVal);
             }
 
             // If a fixed width was requested
-            else if (requestedWidth.HasValue)
+            if (requestedWidth.HasValue)
             {
                 if (threedFormat.HasValue)
                 {
                     // This method can handle 0 being passed in for the requested height
                     return GetFixedSwScaleFilter(threedFormat, requestedWidth.Value, 0);
                 }
-                else
-                {
-                    var widthParam = requestedWidth.Value.ToString(CultureInfo.InvariantCulture);
 
-                    return string.Format(
-                            CultureInfo.InvariantCulture,
-                            "scale={0}:trunc(ow/a/2)*2",
-                            widthParam);
-                }
+                var widthParam = requestedWidth.Value.ToString(CultureInfo.InvariantCulture);
+
+                return string.Format(
+                    CultureInfo.InvariantCulture,
+                    "scale={0}:trunc(ow/a/2)*2",
+                    widthParam);
             }
 
             // If a fixed height was requested
-            else if (requestedHeight.HasValue)
+            if (requestedHeight.HasValue)
             {
                 var heightParam = requestedHeight.Value.ToString(CultureInfo.InvariantCulture);
 
                 return string.Format(
-                        CultureInfo.InvariantCulture,
-                        "scale=trunc(oh*a/{1})*{1}:{0}",
-                        heightParam,
-                        scaleVal);
+                    CultureInfo.InvariantCulture,
+                    "scale=trunc(oh*a/{1})*{1}:{0}",
+                    heightParam,
+                    scaleVal);
             }
 
             // If a max width was requested
-            else if (requestedMaxWidth.HasValue)
+            if (requestedMaxWidth.HasValue)
             {
                 var maxWidthParam = requestedMaxWidth.Value.ToString(CultureInfo.InvariantCulture);
 
                 return string.Format(
-                        CultureInfo.InvariantCulture,
-                        "scale=trunc(min(max(iw\\,ih*a)\\,{0})/{1})*{1}:trunc(ow/a/2)*2",
-                        maxWidthParam,
-                        scaleVal);
+                    CultureInfo.InvariantCulture,
+                    "scale=trunc(min(max(iw\\,ih*a)\\,{0})/{1})*{1}:trunc(ow/a/2)*2",
+                    maxWidthParam,
+                    scaleVal);
             }
 
             // If a max height was requested
-            else if (requestedMaxHeight.HasValue)
+            if (requestedMaxHeight.HasValue)
             {
                 var maxHeightParam = requestedMaxHeight.Value.ToString(CultureInfo.InvariantCulture);
 
                 return string.Format(
-                        CultureInfo.InvariantCulture,
-                        "scale=trunc(oh*a/{1})*{1}:min(max(iw/a\\,ih)\\,{0})",
-                        maxHeightParam,
-                        scaleVal);
+                    CultureInfo.InvariantCulture,
+                    "scale=trunc(oh*a/{1})*{1}:min(max(iw/a\\,ih)\\,{0})",
+                    maxHeightParam,
+                    scaleVal);
             }
 
             return string.Empty;
@@ -2912,18 +2904,21 @@ namespace MediaBrowser.Controller.MediaEncoding
                     "yadif_cuda={0}:-1:0",
                     doubleRateDeint ? "1" : "0");
             }
-            else if (hwDeintSuffix.Contains("vaapi", StringComparison.OrdinalIgnoreCase))
+
+            if (hwDeintSuffix.Contains("vaapi", StringComparison.OrdinalIgnoreCase))
             {
                 return string.Format(
                     CultureInfo.InvariantCulture,
                     "deinterlace_vaapi=rate={0}",
                     doubleRateDeint ? "field" : "frame");
             }
-            else if (hwDeintSuffix.Contains("qsv", StringComparison.OrdinalIgnoreCase))
+
+            if (hwDeintSuffix.Contains("qsv", StringComparison.OrdinalIgnoreCase))
             {
                 return "deinterlace_qsv=mode=2";
             }
-            else if (hwDeintSuffix.Contains("videotoolbox", StringComparison.OrdinalIgnoreCase))
+
+            if (hwDeintSuffix.Contains("videotoolbox", StringComparison.OrdinalIgnoreCase))
             {
                 return string.Format(
                     CultureInfo.InvariantCulture,
@@ -2954,7 +2949,8 @@ namespace MediaBrowser.Controller.MediaEncoding
                         options.VppTonemappingBrightness,
                         options.VppTonemappingContrast);
             }
-            else if (string.Equals(hwTonemapSuffix, "vulkan", StringComparison.OrdinalIgnoreCase))
+
+            if (string.Equals(hwTonemapSuffix, "vulkan", StringComparison.OrdinalIgnoreCase))
             {
                 args = "libplacebo=format={1}:tonemapping={2}:color_primaries=bt709:color_trc=bt709:colorspace=bt709:peak_detect=0:upscaler=none:downscaler=none";
 
@@ -4830,26 +4826,27 @@ namespace MediaBrowser.Controller.MediaEncoding
                 {
                     return videoStream.BitDepth.Value;
                 }
-                else if (string.Equals(videoStream.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
-                         || string.Equals(videoStream.PixelFormat, "yuvj420p", StringComparison.OrdinalIgnoreCase)
-                         || string.Equals(videoStream.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
+
+                if (string.Equals(videoStream.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
+                    || string.Equals(videoStream.PixelFormat, "yuvj420p", StringComparison.OrdinalIgnoreCase)
+                    || string.Equals(videoStream.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
                 {
                     return 8;
                 }
-                else if (string.Equals(videoStream.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase)
-                         || string.Equals(videoStream.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreCase))
+
+                if (string.Equals(videoStream.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase)
+                    || string.Equals(videoStream.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreCase))
                 {
                     return 10;
                 }
-                else if (string.Equals(videoStream.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase)
-                         || string.Equals(videoStream.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreCase))
+
+                if (string.Equals(videoStream.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase)
+                    || string.Equals(videoStream.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreCase))
                 {
                     return 12;
                 }
-                else
-                {
-                    return 8;
-                }
+
+                return 8;
             }
 
             return 0;
@@ -5081,11 +5078,9 @@ namespace MediaBrowser.Controller.MediaEncoding
                         return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty)
                             + (nvdecNoInternalCopy ? " -hwaccel_flags +unsafe_output" : string.Empty) + " -threads 1" + (isAv1 ? " -c:v av1" : string.Empty);
                     }
-                    else
-                    {
-                        // cuvid decoder doesn't have threading issue.
-                        return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty);
-                    }
+
+                    // cuvid decoder doesn't have threading issue.
+                    return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty);
                 }
             }
 
@@ -5443,7 +5438,8 @@ namespace MediaBrowser.Controller.MediaEncoding
                 // Automatically set thread count
                 return mustSetThreadCount ? Math.Max(Environment.ProcessorCount - 1, 1) : 0;
             }
-            else if (threads >= Environment.ProcessorCount)
+
+            if (threads >= Environment.ProcessorCount)
             {
                 return Environment.ProcessorCount;
             }

+ 0 - 1
MediaBrowser.Controller/Session/ISessionManager.cs

@@ -7,7 +7,6 @@ using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
 using Jellyfin.Data.Entities.Security;
-using Jellyfin.Data.Events;
 using MediaBrowser.Controller.Authentication;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Session;

+ 0 - 1
MediaBrowser.Controller/Subtitles/ISubtitleManager.cs

@@ -1,7 +1,6 @@
 #pragma warning disable CS1591
 
 using System;
-using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Entities;

+ 3 - 5
MediaBrowser.Controller/SyncPlay/GroupStates/WaitingGroupState.cs

@@ -533,11 +533,9 @@ namespace MediaBrowser.Controller.SyncPlay.GroupStates
                     _logger.LogWarning("Session {SessionId} is seeking to wrong position, correcting.", session.Id);
                     return;
                 }
-                else
-                {
-                    // Session is ready.
-                    context.SetBuffering(session, false);
-                }
+
+                // Session is ready.
+                context.SetBuffering(session, false);
 
                 if (!context.IsBuffering())
                 {

+ 11 - 18
MediaBrowser.Controller/SyncPlay/Queue/PlayQueueManager.cs

@@ -313,17 +313,13 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
 
                     return true;
                 }
-                else
-                {
-                    // Restoring playing item.
-                    SetPlayingItemByPlaylistId(playingItem.PlaylistItemId);
-                    return false;
-                }
-            }
-            else
-            {
+
+                // Restoring playing item.
+                SetPlayingItemByPlaylistId(playingItem.PlaylistItemId);
                 return false;
             }
+
+            return false;
         }
 
         /// <summary>
@@ -528,10 +524,8 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
             {
                 return _shuffledPlaylist;
             }
-            else
-            {
-                return _sortedPlaylist;
-            }
+
+            return _sortedPlaylist;
         }
 
         /// <summary>
@@ -544,14 +538,13 @@ namespace MediaBrowser.Controller.SyncPlay.Queue
             {
                 return null;
             }
-            else if (ShuffleMode.Equals(GroupShuffleMode.Shuffle))
+
+            if (ShuffleMode.Equals(GroupShuffleMode.Shuffle))
             {
                 return _shuffledPlaylist[PlayingItemIndex];
             }
-            else
-            {
-                return _sortedPlaylist[PlayingItemIndex];
-            }
+
+            return _sortedPlaylist[PlayingItemIndex];
         }
     }
 }

+ 1 - 4
MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs

@@ -73,10 +73,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
             foreach (var info in idInfos)
             {
                 var id = info.Key + "Id";
-                if (!_validProviderIds.ContainsKey(id))
-                {
-                    _validProviderIds.Add(id, info.Key);
-                }
+                _validProviderIds.TryAdd(id, info.Key);
             }
 
             // Additional Mappings

+ 1 - 1
MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs

@@ -375,7 +375,7 @@ namespace MediaBrowser.LocalMetadata.Savers
                     await writer.WriteStartElementAsync(null, "Person", null).ConfigureAwait(false);
                     await writer.WriteElementStringAsync(null, "Name", null, person.Name).ConfigureAwait(false);
                     await writer.WriteElementStringAsync(null, "Type", null, person.Type.ToString()).ConfigureAwait(false);
-                    await writer.WriteElementStringAsync(null, "Role", null, person.Role.ToString()).ConfigureAwait(false);
+                    await writer.WriteElementStringAsync(null, "Role", null, person.Role).ConfigureAwait(false);
 
                     if (person.SortOrder.HasValue)
                     {

+ 4 - 8
MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs

@@ -231,10 +231,8 @@ namespace MediaBrowser.MediaEncoding.Attachments
                 throw new InvalidOperationException(
                     string.Format(CultureInfo.InvariantCulture, "ffmpeg attachment extraction failed for {0} to {1}", inputPath, outputPath));
             }
-            else
-            {
-                _logger.LogInformation("ffmpeg attachment extraction completed for {Path} to {Path}", inputPath, outputPath);
-            }
+
+            _logger.LogInformation("ffmpeg attachment extraction completed for {InputPath} to {OutputPath}", inputPath, outputPath);
         }
 
         private async Task<Stream> GetAttachmentStream(
@@ -376,10 +374,8 @@ namespace MediaBrowser.MediaEncoding.Attachments
                 throw new InvalidOperationException(
                     string.Format(CultureInfo.InvariantCulture, "ffmpeg attachment extraction failed for {0} to {1}", inputPath, outputPath));
             }
-            else
-            {
-                _logger.LogInformation("ffmpeg attachment extraction completed for {Path} to {Path}", inputPath, outputPath);
-            }
+
+            _logger.LogInformation("ffmpeg attachment extraction completed for {InputPath} to {OutputPath}", inputPath, outputPath);
         }
 
         private string GetAttachmentCachePath(string mediaPath, MediaSourceInfo mediaSource, int attachmentStreamIndex)

+ 1 - 2
MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs

@@ -1,4 +1,3 @@
-using System;
 using System.IO;
 using System.Linq;
 using BDInfo.IO;
@@ -105,7 +104,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo
                 _impl.FullName,
                 new[] { searchPattern },
                 false,
-                (searchOption & SearchOption.AllDirectories) == SearchOption.AllDirectories)
+                searchOption == SearchOption.AllDirectories)
             .Select(x => new BdInfoFileInfo(x))
             .ToArray();
     }

+ 4 - 4
MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs

@@ -217,12 +217,14 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
                 return false;
             }
-            else if (version < MinVersion) // Version is below what we recommend
+
+            if (version < MinVersion) // Version is below what we recommend
             {
                 _logger.LogWarning("FFmpeg validation: The minimum recommended version is {MinVersion}", MinVersion);
                 return false;
             }
-            else if (MaxVersion is not null && version > MaxVersion) // Version is above what we recommend
+
+            if (MaxVersion is not null && version > MaxVersion) // Version is above what we recommend
             {
                 _logger.LogWarning("FFmpeg validation: The maximum recommended version is {MaxVersion}", MaxVersion);
                 return false;
@@ -491,7 +493,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
             var found = Regex
                 .Matches(output, @"^\s\S{6}\s(?<codec>[\w|-]+)\s+.+$", RegexOptions.Multiline)
-                .Cast<Match>()
                 .Select(x => x.Groups["codec"].Value)
                 .Where(x => required.Contains(x));
 
@@ -520,7 +521,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
             var found = Regex
                 .Matches(output, @"^\s\S{3}\s(?<filter>[\w|-]+)\s+.+$", RegexOptions.Multiline)
-                .Cast<Match>()
                 .Select(x => x.Groups["filter"].Value)
                 .Where(x => _requiredFilters.Contains(x));
 

+ 3 - 5
MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs

@@ -449,7 +449,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
                 {
                     try
                     {
-                        _logger.LogInformation("Deleting converted subtitle due to failure: ", outputPath);
+                        _logger.LogInformation("Deleting converted subtitle due to failure: {Path}", outputPath);
                         _fileSystem.DeleteFile(outputPath);
                     }
                     catch (IOException ex)
@@ -624,10 +624,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
                 throw new FfmpegException(
                     string.Format(CultureInfo.InvariantCulture, "ffmpeg subtitle extraction failed for {0} to {1}", inputPath, outputPath));
             }
-            else
-            {
-                _logger.LogInformation("ffmpeg subtitle extraction completed for {InputPath} to {OutputPath}", inputPath, outputPath);
-            }
+
+            _logger.LogInformation("ffmpeg subtitle extraction completed for {InputPath} to {OutputPath}", inputPath, outputPath);
 
             if (string.Equals(outputCodec, "ass", StringComparison.OrdinalIgnoreCase))
             {

+ 0 - 1
MediaBrowser.Model/Configuration/ServerConfiguration.cs

@@ -2,7 +2,6 @@
 #pragma warning disable CA1819
 
 using System;
-using System.Collections.Generic;
 using MediaBrowser.Model.Drawing;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Updates;

+ 2 - 1
MediaBrowser.Model/Cryptography/PasswordHash.cs

@@ -80,7 +80,8 @@ namespace MediaBrowser.Model.Cryptography
             {
                 throw new FormatException("Hash string must contain a valid id");
             }
-            else if (nextSegment == -1)
+
+            if (nextSegment == -1)
             {
                 return new PasswordHash(hashString.ToString(), Array.Empty<byte>());
             }

+ 16 - 8
MediaBrowser.Model/Dlna/StreamBuilder.cs

@@ -1075,31 +1075,38 @@ namespace MediaBrowser.Model.Dlna
             {
                 return 128000;
             }
-            else if (totalBitrate <= 2000000)
+
+            if (totalBitrate <= 2000000)
             {
                 return 384000;
             }
-            else if (totalBitrate <= 3000000)
+
+            if (totalBitrate <= 3000000)
             {
                 return 448000;
             }
-            else if (totalBitrate <= 4000000)
+
+            if (totalBitrate <= 4000000)
             {
                 return 640000;
             }
-            else if (totalBitrate <= 5000000)
+
+            if (totalBitrate <= 5000000)
             {
                 return 768000;
             }
-            else if (totalBitrate <= 10000000)
+
+            if (totalBitrate <= 10000000)
             {
                 return 1536000;
             }
-            else if (totalBitrate <= 15000000)
+
+            if (totalBitrate <= 15000000)
             {
                 return 2304000;
             }
-            else if (totalBitrate <= 20000000)
+
+            if (totalBitrate <= 20000000)
             {
                 return 3584000;
             }
@@ -1443,7 +1450,8 @@ namespace MediaBrowser.Model.Dlna
                 {
                     return false;
                 }
-                else if (ContainerProfile.ContainsContainer(normalizedContainers, "mkv")
+
+                if (ContainerProfile.ContainsContainer(normalizedContainers, "mkv")
                     || ContainerProfile.ContainsContainer(normalizedContainers, "matroska"))
                 {
                     return true;

+ 1 - 1
MediaBrowser.Model/Dlna/StreamInfo.cs

@@ -430,7 +430,7 @@ namespace MediaBrowser.Model.Dlna
 
                     return totalBitrate.HasValue ?
                         Convert.ToInt64(totalBitrate.Value * totalSeconds) :
-                        (long?)null;
+                        null;
                 }
 
                 return null;

+ 4 - 2
MediaBrowser.Model/MediaInfo/AudioCodec.cs

@@ -17,11 +17,13 @@ namespace MediaBrowser.Model.MediaInfo
             {
                 return "Dolby Digital";
             }
-            else if (string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
+
+            if (string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
             {
                 return "Dolby Digital+";
             }
-            else if (string.Equals(codec, "dca", StringComparison.OrdinalIgnoreCase))
+
+            if (string.Equals(codec, "dca", StringComparison.OrdinalIgnoreCase))
             {
                 return "DTS";
             }

+ 0 - 1
MediaBrowser.Providers/Lyric/TxtLyricProvider.cs

@@ -1,6 +1,5 @@
 using System.Collections.Generic;
 using System.IO;
-using System.Linq;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Lyrics;

+ 1 - 4
MediaBrowser.Providers/Manager/MetadataService.cs

@@ -882,10 +882,7 @@ namespace MediaBrowser.Providers.Manager
                 var key = providerId.Key;
 
                 // Don't replace existing Id's.
-                if (!lookupInfo.ProviderIds.ContainsKey(key))
-                {
-                    lookupInfo.ProviderIds[key] = providerId.Value;
-                }
+                lookupInfo.ProviderIds.TryAdd(key, providerId.Value);
             }
         }
 

+ 1 - 4
MediaBrowser.Providers/Manager/ProviderManager.cs

@@ -780,10 +780,7 @@ namespace MediaBrowser.Providers.Manager
                         {
                             foreach (var providerId in result.ProviderIds)
                             {
-                                if (!existingMatch.ProviderIds.ContainsKey(providerId.Key))
-                                {
-                                    existingMatch.ProviderIds.Add(providerId.Key, providerId.Value);
-                                }
+                                existingMatch.ProviderIds.TryAdd(providerId.Key, providerId.Value);
                             }
 
                             if (string.IsNullOrWhiteSpace(existingMatch.ImageUrl))

+ 1 - 4
MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs

@@ -100,10 +100,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
             foreach (var info in idInfos)
             {
                 var id = info.Key + "Id";
-                if (!_validProviderIds.ContainsKey(id))
-                {
-                    _validProviderIds.Add(id, info.Key);
-                }
+                _validProviderIds.TryAdd(id, info.Key);
             }
 
             // Additional Mappings

+ 2 - 4
RSSDP/HttpParserBase.cs

@@ -221,10 +221,8 @@ namespace Rssdp.Infrastructure
             {
                 return trimmedSegment.Substring(1, trimmedSegment.Length - 2);
             }
-            else
-            {
-                return trimmedSegment;
-            }
+
+            return trimmedSegment;
         }
     }
 }

+ 1 - 2
RSSDP/HttpRequestParser.cs

@@ -64,8 +64,7 @@ namespace Rssdp.Infrastructure
             }
 
             message.Method = new HttpMethod(parts[0].Trim());
-            Uri requestUri;
-            if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
+            if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out var requestUri))
             {
                 message.RequestUri = requestUri;
             }

+ 1 - 2
RSSDP/HttpResponseParser.cs

@@ -77,8 +77,7 @@ namespace Rssdp.Infrastructure
 
             message.Version = ParseHttpVersion(parts[0].Trim());
 
-            int statusCode = -1;
-            if (!Int32.TryParse(parts[1].Trim(), out statusCode))
+            if (!Int32.TryParse(parts[1].Trim(), out var statusCode))
             {
                 throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));
             }

+ 2 - 4
RSSDP/SsdpDevice.cs

@@ -171,10 +171,8 @@ namespace Rssdp
                 {
                     return "uuid:" + this.Uuid;
                 }
-                else
-                {
-                    return _Udn;
-                }
+
+                return _Udn;
             }
 
             set

+ 4 - 8
RSSDP/SsdpDeviceLocator.cs

@@ -483,8 +483,7 @@ namespace Rssdp.Infrastructure
                 }
             }
 
-            Uri retVal;
-            Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out retVal);
+            Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out var retVal);
             return retVal;
         }
 
@@ -501,8 +500,7 @@ namespace Rssdp.Infrastructure
                 }
             }
 
-            Uri retVal;
-            Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out retVal);
+            Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out var retVal);
             return retVal;
         }
 
@@ -587,10 +585,8 @@ namespace Rssdp.Infrastructure
             {
                 return OneSecond;
             }
-            else
-            {
-                return searchWaitTime.Subtract(OneSecond);
-            }
+
+            return searchWaitTime.Subtract(OneSecond);
         }
 
         private DiscoveredSsdpDevice FindExistingDeviceNotification(IEnumerable<DiscoveredSsdpDevice> devices, string notificationType, string usn)

+ 5 - 9
RSSDP/SsdpDevicePublisher.cs

@@ -244,7 +244,6 @@ namespace Rssdp.Infrastructure
             // Wait on random interval up to MX, as per SSDP spec.
             // Also, as per UPnP 1.1/SSDP spec ignore missing/bank MX header. If over 120, assume random value between 0 and 120.
             // Using 16 as minimum as that's often the minimum system clock frequency anyway.
-            int maxWaitInterval = 0;
             if (String.IsNullOrEmpty(mx))
             {
                 // Windows Explorer is poorly behaved and doesn't supply an MX header value.
@@ -254,7 +253,7 @@ namespace Rssdp.Infrastructure
                 // return;
             }
 
-            if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0)
+            if (!Int32.TryParse(mx, out var maxWaitInterval) || maxWaitInterval <= 0)
             {
                 return;
             }
@@ -572,17 +571,14 @@ namespace Rssdp.Infrastructure
             {
                 return nonzeroCacheLifetimesQuery.Min();
             }
-            else
-            {
-                return TimeSpan.Zero;
-            }
+
+            return TimeSpan.Zero;
         }
 
         private string GetFirstHeaderValue(System.Net.Http.Headers.HttpRequestHeaders httpRequestHeaders, string headerName)
         {
             string retVal = null;
-            IEnumerable<String> values = null;
-            if (httpRequestHeaders.TryGetValues(headerName, out values) && values != null)
+            if (httpRequestHeaders.TryGetValues(headerName, out var values) && values != null)
             {
                 retVal = values.FirstOrDefault();
             }
@@ -644,7 +640,7 @@ namespace Rssdp.Infrastructure
 
             public string Key
             {
-                get { return this.SearchTarget + ":" + this.EndPoint.ToString(); }
+                get { return this.SearchTarget + ":" + this.EndPoint; }
             }
 
             public bool IsOld()

+ 10 - 5
src/Jellyfin.Extensions/AlphanumericComparator.cs

@@ -20,11 +20,13 @@ namespace Jellyfin.Extensions
             {
                 return 0;
             }
-            else if (s1 is null)
+
+            if (s1 is null)
             {
                 return -1;
             }
-            else if (s2 is null)
+
+            if (s2 is null)
             {
                 return 1;
             }
@@ -37,11 +39,13 @@ namespace Jellyfin.Extensions
             {
                 return 0;
             }
-            else if (len1 == 0)
+
+            if (len1 == 0)
             {
                 return -1;
             }
-            else if (len2 == 0)
+
+            if (len2 == 0)
             {
                 return 1;
             }
@@ -82,7 +86,8 @@ namespace Jellyfin.Extensions
                     {
                         return -1;
                     }
-                    else if (span1Len > span2Len)
+
+                    if (span1Len > span2Len)
                     {
                         return 1;
                     }

+ 0 - 1
src/Jellyfin.Extensions/Json/Converters/JsonBoolStringConverter.cs

@@ -1,7 +1,6 @@
 using System;
 using System.Buffers;
 using System.Buffers.Text;
-using System.Linq;
 using System.Text.Json;
 using System.Text.Json.Serialization;
 

+ 0 - 2
src/Jellyfin.Extensions/StringExtensions.cs

@@ -1,6 +1,4 @@
 using System;
-using System.Globalization;
-using System.Text;
 using System.Text.RegularExpressions;
 
 namespace Jellyfin.Extensions

+ 0 - 1
tests/Jellyfin.Api.Tests/Auth/FirstTimeSetupPolicy/FirstTimeSetupHandlerTests.cs

@@ -2,7 +2,6 @@ using System.Collections.Generic;
 using System.Threading.Tasks;
 using AutoFixture;
 using AutoFixture.AutoMoq;
-using Jellyfin.Api.Auth.DefaultAuthorizationPolicy;
 using Jellyfin.Api.Auth.FirstTimeSetupPolicy;
 using Jellyfin.Api.Constants;
 using MediaBrowser.Common.Configuration;

+ 0 - 1
tests/Jellyfin.Api.Tests/Controllers/ImageControllerTests.cs

@@ -1,4 +1,3 @@
-using System;
 using Jellyfin.Api.Controllers;
 using Xunit;
 

+ 3 - 3
tests/Jellyfin.Model.Tests/Dlna/StreamBuilderTests.cs

@@ -162,7 +162,7 @@ namespace Jellyfin.Model.Tests
         [InlineData("Tizen4-4K-5.1", "mkv-vp9-aac-srt-2600k", PlayMethod.DirectPlay)]
         [InlineData("Tizen4-4K-5.1", "mkv-vp9-ac3-srt-2600k", PlayMethod.DirectPlay)]
         [InlineData("Tizen4-4K-5.1", "mkv-vp9-vorbis-vtt-2600k", PlayMethod.DirectPlay)]
-        public async Task BuildVideoItemSimple(string deviceName, string mediaSource, PlayMethod? playMethod, TranscodeReason why = (TranscodeReason)0, string transcodeMode = "DirectStream", string transcodeProtocol = "")
+        public async Task BuildVideoItemSimple(string deviceName, string mediaSource, PlayMethod? playMethod, TranscodeReason why = default, string transcodeMode = "DirectStream", string transcodeProtocol = "")
         {
             var options = await GetMediaOptions(deviceName, mediaSource);
             BuildVideoItemSimpleTest(options, playMethod, why, transcodeMode, transcodeProtocol);
@@ -260,7 +260,7 @@ namespace Jellyfin.Model.Tests
         [InlineData("Tizen4-4K-5.1", "mkv-vp9-aac-srt-2600k", PlayMethod.DirectPlay)]
         [InlineData("Tizen4-4K-5.1", "mkv-vp9-ac3-srt-2600k", PlayMethod.DirectPlay)]
         [InlineData("Tizen4-4K-5.1", "mkv-vp9-vorbis-vtt-2600k", PlayMethod.DirectPlay)]
-        public async Task BuildVideoItemWithFirstExplicitStream(string deviceName, string mediaSource, PlayMethod? playMethod, TranscodeReason why = (TranscodeReason)0, string transcodeMode = "DirectStream", string transcodeProtocol = "")
+        public async Task BuildVideoItemWithFirstExplicitStream(string deviceName, string mediaSource, PlayMethod? playMethod, TranscodeReason why = default, string transcodeMode = "DirectStream", string transcodeProtocol = "")
         {
             var options = await GetMediaOptions(deviceName, mediaSource);
             options.AudioStreamIndex = 1;
@@ -296,7 +296,7 @@ namespace Jellyfin.Model.Tests
         // Tizen 4 4K 5.1
         [InlineData("Tizen4-4K-5.1", "mp4-h264-ac3-aac-srt-2600k", PlayMethod.DirectPlay, (TranscodeReason)0, "Remux")]
         [InlineData("Tizen4-4K-5.1", "mp4-hevc-ac3-aac-srt-15200k", PlayMethod.DirectPlay, (TranscodeReason)0, "Remux")]
-        public async Task BuildVideoItemWithDirectPlayExplicitStreams(string deviceName, string mediaSource, PlayMethod? playMethod, TranscodeReason why = (TranscodeReason)0, string transcodeMode = "DirectStream", string transcodeProtocol = "")
+        public async Task BuildVideoItemWithDirectPlayExplicitStreams(string deviceName, string mediaSource, PlayMethod? playMethod, TranscodeReason why = default, string transcodeMode = "DirectStream", string transcodeProtocol = "")
         {
             var options = await GetMediaOptions(deviceName, mediaSource);
             var streamCount = options.MediaSources[0].MediaStreams.Count;

+ 2 - 5
tests/Jellyfin.Providers.Tests/Manager/MetadataServiceTests.cs

@@ -238,9 +238,6 @@ namespace Jellyfin.Providers.Tests.Manager
                     }
                 };
 
-            object? result;
-            List<PersonInfo> actual;
-
             // overwrite provider id
             var overwriteNewValue = new List<PersonInfo>
             {
@@ -249,9 +246,9 @@ namespace Jellyfin.Providers.Tests.Manager
                     Name = "Name 2"
                 }
             };
-            Assert.False(TestMergeBaseItemDataPerson(GetOldValue(), overwriteNewValue, null, false, out result));
+            Assert.False(TestMergeBaseItemDataPerson(GetOldValue(), overwriteNewValue, null, false, out var result));
             // People not already in target are not merged into it from source
-            actual = (List<PersonInfo>)result!;
+            List<PersonInfo> actual = (List<PersonInfo>)result!;
             Assert.Single(actual);
             Assert.Equal("Name 1", actual[0].Name);
 

+ 1 - 1
tests/Jellyfin.XbmcMetadata.Tests/Parsers/SeriesNfoParserTests.cs

@@ -90,7 +90,7 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
             };
 
             _parser.Fetch(result, path, CancellationToken.None);
-            var item = (Series)result.Item;
+            var item = result.Item;
 
             Assert.Equal(id, item.ProviderIds[provider]);
         }