Merge pull request #6857 from Bond-009/warn56

This commit is contained in:
Cody Robibero 2021-11-16 12:25:54 -07:00 committed by GitHub
commit 84b8c9c2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 34 additions and 46 deletions

View File

@ -1075,14 +1075,6 @@ namespace Emby.Server.Implementations.Channels
forceUpdate = true;
}
// was used for status
// if (!string.Equals(item.ExternalEtag ?? string.Empty, info.Etag ?? string.Empty, StringComparison.Ordinal))
// {
// item.ExternalEtag = info.Etag;
// forceUpdate = true;
// _logger.LogDebug("Forcing update due to ExternalEtag {0}", item.Name);
// }
if (!internalChannelId.Equals(item.ChannelId))
{
forceUpdate = true;

View File

@ -1,4 +1,6 @@
using System;
#pragma warning disable CA1813 // Avoid unsealed attributes
using System;
namespace Jellyfin.Api.Attributes
{

View File

@ -3,7 +3,7 @@
/// <summary>
/// Produces file attribute of "image/*".
/// </summary>
public class AcceptsImageFileAttribute : AcceptsFileAttribute
public sealed class AcceptsImageFileAttribute : AcceptsFileAttribute
{
private const string ContentType = "image/*";

View File

@ -7,7 +7,7 @@ namespace Jellyfin.Api.Attributes
/// <summary>
/// Identifies an action that supports the HTTP GET method.
/// </summary>
public class HttpSubscribeAttribute : HttpMethodAttribute
public sealed class HttpSubscribeAttribute : HttpMethodAttribute
{
private static readonly IEnumerable<string> _supportedMethods = new[] { "SUBSCRIBE" };

View File

@ -7,7 +7,7 @@ namespace Jellyfin.Api.Attributes
/// <summary>
/// Identifies an action that supports the HTTP GET method.
/// </summary>
public class HttpUnsubscribeAttribute : HttpMethodAttribute
public sealed class HttpUnsubscribeAttribute : HttpMethodAttribute
{
private static readonly IEnumerable<string> _supportedMethods = new[] { "UNSUBSCRIBE" };

View File

@ -6,7 +6,7 @@ namespace Jellyfin.Api.Attributes
/// Attribute to mark a parameter as obsolete.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public class ParameterObsoleteAttribute : Attribute
public sealed class ParameterObsoleteAttribute : Attribute
{
}
}

View File

@ -3,7 +3,7 @@
/// <summary>
/// Produces file attribute of "image/*".
/// </summary>
public class ProducesAudioFileAttribute : ProducesFileAttribute
public sealed class ProducesAudioFileAttribute : ProducesFileAttribute
{
private const string ContentType = "audio/*";

View File

@ -1,4 +1,6 @@
using System;
#pragma warning disable CA1813 // Avoid unsealed attributes
using System;
namespace Jellyfin.Api.Attributes
{

View File

@ -3,7 +3,7 @@
/// <summary>
/// Produces file attribute of "image/*".
/// </summary>
public class ProducesImageFileAttribute : ProducesFileAttribute
public sealed class ProducesImageFileAttribute : ProducesFileAttribute
{
private const string ContentType = "image/*";

View File

@ -3,7 +3,7 @@
/// <summary>
/// Produces file attribute of "image/*".
/// </summary>
public class ProducesPlaylistFileAttribute : ProducesFileAttribute
public sealed class ProducesPlaylistFileAttribute : ProducesFileAttribute
{
private const string ContentType = "application/x-mpegURL";

View File

@ -3,7 +3,7 @@
/// <summary>
/// Produces file attribute of "video/*".
/// </summary>
public class ProducesVideoFileAttribute : ProducesFileAttribute
public sealed class ProducesVideoFileAttribute : ProducesFileAttribute
{
private const string ContentType = "video/*";

View File

@ -146,11 +146,7 @@ namespace MediaBrowser.Controller.Entities.Audio
return info;
}
protected override List<Tuple<BaseItem, MediaSourceType>> GetAllItemsForMediaSources()
{
var list = new List<Tuple<BaseItem, MediaSourceType>>();
list.Add(new Tuple<BaseItem, MediaSourceType>(this, MediaSourceType.Default));
return list;
}
protected override IEnumerable<(BaseItem, MediaSourceType)> GetAllItemsForMediaSources()
=> new[] { ((BaseItem)this, MediaSourceType.Default) };
}
}

View File

@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
@ -333,13 +332,6 @@ namespace MediaBrowser.Controller.Entities
[JsonIgnore]
public string ExternalSeriesId { get; set; }
/// <summary>
/// Gets or sets the etag.
/// </summary>
/// <value>The etag.</value>
[JsonIgnore]
public string ExternalEtag { get; set; }
[JsonIgnore]
public virtual bool IsHidden => false;
@ -1161,9 +1153,9 @@ namespace MediaBrowser.Controller.Entities
.ToList();
}
protected virtual List<Tuple<BaseItem, MediaSourceType>> GetAllItemsForMediaSources()
protected virtual IEnumerable<(BaseItem, MediaSourceType)> GetAllItemsForMediaSources()
{
return new List<Tuple<BaseItem, MediaSourceType>>();
return Enumerable.Empty<(BaseItem, MediaSourceType)>();
}
private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type)

View File

@ -509,35 +509,35 @@ namespace MediaBrowser.Controller.Entities
}).FirstOrDefault();
}
protected override List<Tuple<BaseItem, MediaSourceType>> GetAllItemsForMediaSources()
protected override IEnumerable<(BaseItem, MediaSourceType)> GetAllItemsForMediaSources()
{
var list = new List<Tuple<BaseItem, MediaSourceType>>();
var list = new List<(BaseItem, MediaSourceType)>
{
(this, MediaSourceType.Default)
};
list.Add(new Tuple<BaseItem, MediaSourceType>(this, MediaSourceType.Default));
list.AddRange(GetLinkedAlternateVersions().Select(i => new Tuple<BaseItem, MediaSourceType>(i, MediaSourceType.Grouping)));
list.AddRange(GetLinkedAlternateVersions().Select(i => ((BaseItem)i, MediaSourceType.Grouping)));
if (!string.IsNullOrEmpty(PrimaryVersionId))
{
var primary = LibraryManager.GetItemById(PrimaryVersionId) as Video;
if (primary != null)
if (LibraryManager.GetItemById(PrimaryVersionId) is Video primary)
{
var existingIds = list.Select(i => i.Item1.Id).ToList();
list.Add(new Tuple<BaseItem, MediaSourceType>(primary, MediaSourceType.Grouping));
list.AddRange(primary.GetLinkedAlternateVersions().Where(i => !existingIds.Contains(i.Id)).Select(i => new Tuple<BaseItem, MediaSourceType>(i, MediaSourceType.Grouping)));
list.Add((primary, MediaSourceType.Grouping));
list.AddRange(primary.GetLinkedAlternateVersions().Where(i => !existingIds.Contains(i.Id)).Select(i => ((BaseItem)i, MediaSourceType.Grouping)));
}
}
var localAlternates = list
.SelectMany(i =>
{
var video = i.Item1 as Video;
return video == null ? new List<Guid>() : video.GetLocalAlternateVersionIds();
return i.Item1 is Video video ? video.GetLocalAlternateVersionIds() : Enumerable.Empty<Guid>();
})
.Select(LibraryManager.GetItemById)
.Where(i => i != null)
.ToList();
list.AddRange(localAlternates.Select(i => new Tuple<BaseItem, MediaSourceType>(i, MediaSourceType.Default)));
list.AddRange(localAlternates.Select(i => (i, MediaSourceType.Default)));
return list;
}

View File

@ -191,7 +191,7 @@ namespace MediaBrowser.Model.Net
// Catch-all for all video types that don't require specific mime types
if (_videoFileExtensions.Contains(ext))
{
return "video/" + ext.Substring(1);
return string.Concat("video/", ext.AsSpan(1));
}
// Type text

View File

@ -50,8 +50,12 @@
<Rule Id="CA1725" Action="Error" />
<!-- error on CA1725: Call async methods when in an async method -->
<Rule Id="CA1727" Action="Error" />
<!-- error on CA1813: Avoid unsealed attributes -->
<Rule Id="CA1813" Action="Error" />
<!-- error on CA1843: Do not use 'WaitAll' with a single task -->
<Rule Id="CA1843" Action="Error" />
<!-- error on CA1845: Use span-based 'string.Concat' -->
<Rule Id="CA1845" 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" />