Enable more warnings as errors (#11288)
This commit is contained in:
parent
134bf7a6a5
commit
7d28d08e08
|
@ -109,13 +109,13 @@ namespace Emby.Server.Implementations
|
|||
/// <summary>
|
||||
/// The disposable parts.
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<IDisposable, byte> _disposableParts = new();
|
||||
private readonly ConcurrentBag<IDisposable> _disposableParts = new();
|
||||
private readonly DeviceId _deviceId;
|
||||
|
||||
private readonly IConfiguration _startupConfig;
|
||||
private readonly IXmlSerializer _xmlSerializer;
|
||||
private readonly IStartupOptions _startupOptions;
|
||||
private readonly IPluginManager _pluginManager;
|
||||
private readonly PluginManager _pluginManager;
|
||||
|
||||
private List<Type> _creatingInstances;
|
||||
|
||||
|
@ -161,7 +161,7 @@ namespace Emby.Server.Implementations
|
|||
ApplicationPaths.PluginsPath,
|
||||
ApplicationVersion);
|
||||
|
||||
_disposableParts.TryAdd((PluginManager)_pluginManager, byte.MinValue);
|
||||
_disposableParts.Add(_pluginManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -360,7 +360,7 @@ namespace Emby.Server.Implementations
|
|||
{
|
||||
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>())
|
||||
{
|
||||
_disposableParts.TryAdd(part, byte.MinValue);
|
||||
_disposableParts.Add(part);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,7 @@ namespace Emby.Server.Implementations
|
|||
serviceCollection.AddSingleton<IServerConfigurationManager>(ConfigurationManager);
|
||||
serviceCollection.AddSingleton<IConfigurationManager>(ConfigurationManager);
|
||||
serviceCollection.AddSingleton<IApplicationHost>(this);
|
||||
serviceCollection.AddSingleton(_pluginManager);
|
||||
serviceCollection.AddSingleton<IPluginManager>(_pluginManager);
|
||||
serviceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
|
||||
|
||||
serviceCollection.AddSingleton<IFileSystem, ManagedFileSystem>();
|
||||
|
@ -965,7 +965,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
Logger.LogInformation("Disposing {Type}", type.Name);
|
||||
|
||||
foreach (var (part, _) in _disposableParts)
|
||||
foreach (var part in _disposableParts.ToArray())
|
||||
{
|
||||
var partType = part.GetType();
|
||||
if (partType == type)
|
||||
|
|
|
@ -186,10 +186,7 @@ namespace Emby.Server.Implementations.Data
|
|||
|
||||
protected void CheckDisposed()
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(GetType().Name, "Object has been disposed and cannot be accessed.");
|
||||
}
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -668,12 +668,13 @@ namespace Emby.Server.Implementations.Dto
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -461,7 +461,7 @@ namespace Emby.Server.Implementations.Library
|
|||
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>
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
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);
|
||||
|
||||
// Make sure DateCreated and DateModified have values
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
|||
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
|
||||
{
|
||||
|
|
|
@ -159,10 +159,7 @@ namespace Emby.Server.Implementations.Session
|
|||
|
||||
private void CheckDisposed()
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
}
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
}
|
||||
|
||||
private void OnSessionStarted(SessionInfo info)
|
||||
|
|
|
@ -1271,23 +1271,23 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
{
|
||||
var codec = stream.Codec ?? string.Empty;
|
||||
|
||||
return codec.IndexOf("264", StringComparison.OrdinalIgnoreCase) != -1
|
||||
|| codec.IndexOf("avc", StringComparison.OrdinalIgnoreCase) != -1;
|
||||
return codec.Contains("264", StringComparison.OrdinalIgnoreCase)
|
||||
|| codec.Contains("avc", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static bool IsH265(MediaStream stream)
|
||||
{
|
||||
var codec = stream.Codec ?? string.Empty;
|
||||
|
||||
return codec.IndexOf("265", StringComparison.OrdinalIgnoreCase) != -1
|
||||
|| codec.IndexOf("hevc", StringComparison.OrdinalIgnoreCase) != -1;
|
||||
return codec.Contains("265", StringComparison.OrdinalIgnoreCase)
|
||||
|| codec.Contains("hevc", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static bool IsAAC(MediaStream stream)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -85,6 +85,8 @@
|
|||
<Rule Id="CA1309" Action="Error" />
|
||||
<!-- error on CA1310: Specify StringComparison for correctness -->
|
||||
<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 -->
|
||||
<Rule Id="CA1725" Action="Error" />
|
||||
<!-- error on CA1725: Call async methods when in an async method -->
|
||||
|
@ -101,6 +103,8 @@
|
|||
<Rule Id="CA1849" Action="Error" />
|
||||
<!-- error on CA1851: Possible multiple enumerations of IEnumerable collection -->
|
||||
<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
|
||||
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
|
||||
<Rule Id="CA2016" Action="Error" />
|
||||
|
@ -108,6 +112,8 @@
|
|||
<Rule Id="CA2201" Action="Error" />
|
||||
<!-- error on CA2215: Dispose methods should call base class dispose -->
|
||||
<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 -->
|
||||
<Rule Id="CA2254" Action="Error" />
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user