mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-04 22:24:35 -04:00
Enable more warnings as errors (#11288)
This commit is contained in:
parent
134bf7a6a5
commit
7d28d08e08
@ -109,13 +109,13 @@ namespace Emby.Server.Implementations
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The disposable parts.
|
/// The disposable parts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ConcurrentDictionary<IDisposable, byte> _disposableParts = new();
|
private readonly ConcurrentBag<IDisposable> _disposableParts = new();
|
||||||
private readonly DeviceId _deviceId;
|
private readonly DeviceId _deviceId;
|
||||||
|
|
||||||
private readonly IConfiguration _startupConfig;
|
private readonly IConfiguration _startupConfig;
|
||||||
private readonly IXmlSerializer _xmlSerializer;
|
private readonly IXmlSerializer _xmlSerializer;
|
||||||
private readonly IStartupOptions _startupOptions;
|
private readonly IStartupOptions _startupOptions;
|
||||||
private readonly IPluginManager _pluginManager;
|
private readonly PluginManager _pluginManager;
|
||||||
|
|
||||||
private List<Type> _creatingInstances;
|
private List<Type> _creatingInstances;
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ namespace Emby.Server.Implementations
|
|||||||
ApplicationPaths.PluginsPath,
|
ApplicationPaths.PluginsPath,
|
||||||
ApplicationVersion);
|
ApplicationVersion);
|
||||||
|
|
||||||
_disposableParts.TryAdd((PluginManager)_pluginManager, byte.MinValue);
|
_disposableParts.Add(_pluginManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -360,7 +360,7 @@ namespace Emby.Server.Implementations
|
|||||||
{
|
{
|
||||||
foreach (var part in parts.OfType<IDisposable>())
|
foreach (var part in parts.OfType<IDisposable>())
|
||||||
{
|
{
|
||||||
_disposableParts.TryAdd(part, byte.MinValue);
|
_disposableParts.Add(part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ namespace Emby.Server.Implementations
|
|||||||
{
|
{
|
||||||
foreach (var part in parts.OfType<IDisposable>())
|
foreach (var part in parts.OfType<IDisposable>())
|
||||||
{
|
{
|
||||||
_disposableParts.TryAdd(part, byte.MinValue);
|
_disposableParts.Add(part);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,7 +457,7 @@ namespace Emby.Server.Implementations
|
|||||||
serviceCollection.AddSingleton<IServerConfigurationManager>(ConfigurationManager);
|
serviceCollection.AddSingleton<IServerConfigurationManager>(ConfigurationManager);
|
||||||
serviceCollection.AddSingleton<IConfigurationManager>(ConfigurationManager);
|
serviceCollection.AddSingleton<IConfigurationManager>(ConfigurationManager);
|
||||||
serviceCollection.AddSingleton<IApplicationHost>(this);
|
serviceCollection.AddSingleton<IApplicationHost>(this);
|
||||||
serviceCollection.AddSingleton(_pluginManager);
|
serviceCollection.AddSingleton<IPluginManager>(_pluginManager);
|
||||||
serviceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
|
serviceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
|
||||||
|
|
||||||
serviceCollection.AddSingleton<IFileSystem, ManagedFileSystem>();
|
serviceCollection.AddSingleton<IFileSystem, ManagedFileSystem>();
|
||||||
@ -965,7 +965,7 @@ namespace Emby.Server.Implementations
|
|||||||
|
|
||||||
Logger.LogInformation("Disposing {Type}", type.Name);
|
Logger.LogInformation("Disposing {Type}", type.Name);
|
||||||
|
|
||||||
foreach (var (part, _) in _disposableParts)
|
foreach (var part in _disposableParts.ToArray())
|
||||||
{
|
{
|
||||||
var partType = part.GetType();
|
var partType = part.GetType();
|
||||||
if (partType == type)
|
if (partType == type)
|
||||||
|
@ -186,10 +186,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
protected void CheckDisposed()
|
protected void CheckDisposed()
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(GetType().Name, "Object has been disposed and cannot be accessed.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -668,12 +668,13 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
{
|
{
|
||||||
dto.ImageBlurHashes ??= new Dictionary<ImageType, Dictionary<string, string>>();
|
dto.ImageBlurHashes ??= new Dictionary<ImageType, Dictionary<string, string>>();
|
||||||
|
|
||||||
if (!dto.ImageBlurHashes.ContainsKey(image.Type))
|
if (!dto.ImageBlurHashes.TryGetValue(image.Type, out var value))
|
||||||
{
|
{
|
||||||
dto.ImageBlurHashes[image.Type] = new Dictionary<string, string>();
|
value = new Dictionary<string, string>();
|
||||||
|
dto.ImageBlurHashes[image.Type] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
dto.ImageBlurHashes[image.Type][tag] = image.BlurHash;
|
value[tag] = image.BlurHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
|
@ -461,7 +461,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
ReportItemRemoved(item, parent);
|
ReportItemRemoved(item, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> GetMetadataPaths(BaseItem item, IEnumerable<BaseItem> children)
|
private static List<string> GetMetadataPaths(BaseItem item, IEnumerable<BaseItem> children)
|
||||||
{
|
{
|
||||||
var list = new List<string>
|
var list = new List<string>
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());
|
item.Id = libraryManager.GetNewItemId(item.Path, item.GetType());
|
||||||
|
|
||||||
item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 ||
|
item.IsLocked = item.Path.Contains("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) ||
|
||||||
item.GetParents().Any(i => i.IsLocked);
|
item.GetParents().Any(i => i.IsLocked);
|
||||||
|
|
||||||
// Make sure DateCreated and DateModified have values
|
// Make sure DateCreated and DateModified have values
|
||||||
|
@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename.IndexOf("[boxset]", StringComparison.OrdinalIgnoreCase) != -1 || args.ContainsFileSystemEntryByName("collection.xml"))
|
if (filename.Contains("[boxset]", StringComparison.OrdinalIgnoreCase) || args.ContainsFileSystemEntryByName("collection.xml"))
|
||||||
{
|
{
|
||||||
return new BoxSet
|
return new BoxSet
|
||||||
{
|
{
|
||||||
|
@ -159,10 +159,7 @@ namespace Emby.Server.Implementations.Session
|
|||||||
|
|
||||||
private void CheckDisposed()
|
private void CheckDisposed()
|
||||||
{
|
{
|
||||||
if (_disposed)
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
{
|
|
||||||
throw new ObjectDisposedException(GetType().Name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSessionStarted(SessionInfo info)
|
private void OnSessionStarted(SessionInfo info)
|
||||||
|
@ -1271,23 +1271,23 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
{
|
{
|
||||||
var codec = stream.Codec ?? string.Empty;
|
var codec = stream.Codec ?? string.Empty;
|
||||||
|
|
||||||
return codec.IndexOf("264", StringComparison.OrdinalIgnoreCase) != -1
|
return codec.Contains("264", StringComparison.OrdinalIgnoreCase)
|
||||||
|| codec.IndexOf("avc", StringComparison.OrdinalIgnoreCase) != -1;
|
|| codec.Contains("avc", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsH265(MediaStream stream)
|
public static bool IsH265(MediaStream stream)
|
||||||
{
|
{
|
||||||
var codec = stream.Codec ?? string.Empty;
|
var codec = stream.Codec ?? string.Empty;
|
||||||
|
|
||||||
return codec.IndexOf("265", StringComparison.OrdinalIgnoreCase) != -1
|
return codec.Contains("265", StringComparison.OrdinalIgnoreCase)
|
||||||
|| codec.IndexOf("hevc", StringComparison.OrdinalIgnoreCase) != -1;
|
|| codec.Contains("hevc", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsAAC(MediaStream stream)
|
public static bool IsAAC(MediaStream stream)
|
||||||
{
|
{
|
||||||
var codec = stream.Codec ?? string.Empty;
|
var codec = stream.Codec ?? string.Empty;
|
||||||
|
|
||||||
return codec.IndexOf("aac", StringComparison.OrdinalIgnoreCase) != -1;
|
return codec.Contains("aac", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetBitStreamArgs(MediaStream stream)
|
public static string GetBitStreamArgs(MediaStream stream)
|
||||||
|
@ -85,6 +85,8 @@
|
|||||||
<Rule Id="CA1309" Action="Error" />
|
<Rule Id="CA1309" Action="Error" />
|
||||||
<!-- error on CA1310: Specify StringComparison for correctness -->
|
<!-- error on CA1310: Specify StringComparison for correctness -->
|
||||||
<Rule Id="CA1310" Action="Error" />
|
<Rule Id="CA1310" Action="Error" />
|
||||||
|
<!-- error on CA1513: Use 'ObjectDisposedException.ThrowIf' instead of explicitly throwing a new exception instance -->
|
||||||
|
<Rule Id="CA1513" Action="Error" />
|
||||||
<!-- error on CA1725: Parameter names should match base declaration -->
|
<!-- error on CA1725: Parameter names should match base declaration -->
|
||||||
<Rule Id="CA1725" Action="Error" />
|
<Rule Id="CA1725" Action="Error" />
|
||||||
<!-- error on CA1725: Call async methods when in an async method -->
|
<!-- error on CA1725: Call async methods when in an async method -->
|
||||||
@ -101,6 +103,8 @@
|
|||||||
<Rule Id="CA1849" Action="Error" />
|
<Rule Id="CA1849" Action="Error" />
|
||||||
<!-- error on CA1851: Possible multiple enumerations of IEnumerable collection -->
|
<!-- error on CA1851: Possible multiple enumerations of IEnumerable collection -->
|
||||||
<Rule Id="CA1851" Action="Error" />
|
<Rule Id="CA1851" Action="Error" />
|
||||||
|
<!-- error on CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup -->
|
||||||
|
<Rule Id="CA1854" Action="Error" />
|
||||||
<!-- error on CA2016: Forward the CancellationToken parameter to methods that take one
|
<!-- error on CA2016: Forward the CancellationToken parameter to methods that take one
|
||||||
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
|
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
|
||||||
<Rule Id="CA2016" Action="Error" />
|
<Rule Id="CA2016" Action="Error" />
|
||||||
@ -108,6 +112,8 @@
|
|||||||
<Rule Id="CA2201" Action="Error" />
|
<Rule Id="CA2201" Action="Error" />
|
||||||
<!-- error on CA2215: Dispose methods should call base class dispose -->
|
<!-- error on CA2215: Dispose methods should call base class dispose -->
|
||||||
<Rule Id="CA2215" Action="Error" />
|
<Rule Id="CA2215" Action="Error" />
|
||||||
|
<!-- error on CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability -->
|
||||||
|
<Rule Id="CA2249" Action="Error" />
|
||||||
<!-- error on CA2254: Template should be a static expression -->
|
<!-- error on CA2254: Template should be a static expression -->
|
||||||
<Rule Id="CA2254" Action="Error" />
|
<Rule Id="CA2254" Action="Error" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user