mirror of
https://github.com/jellyfin/jellyfin-plugin-reports.git
synced 2024-11-22 21:29:50 +00:00
Add ruleset, enable error on warn, enable minimun analysis mode
This commit is contained in:
parent
c31dc8d923
commit
281de731e8
@ -1,12 +1,13 @@
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using System;
|
||||
using Jellyfin.Plugin.Reports.Api.Common;
|
||||
using Jellyfin.Plugin.Reports.Api.Data;
|
||||
using Jellyfin.Plugin.Reports.Api.Model;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
namespace Jellyfin.Plugin.Reports.Api.Activities
|
||||
{
|
||||
@ -231,7 +232,7 @@ namespace Jellyfin.Plugin.Reports.Api.Activities
|
||||
{
|
||||
ReportRow rRow = new ReportRow
|
||||
{
|
||||
Id = item.Id.ToString(),
|
||||
Id = item.Id.ToString(CultureInfo.InvariantCulture),
|
||||
UserId = item.UserId
|
||||
};
|
||||
return rRow;
|
||||
|
@ -1,14 +1,16 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using Jellyfin.Plugin.Reports.Api.Data;
|
||||
using Jellyfin.Plugin.Reports.Api.Model;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jellyfin.Plugin.Reports.Api.Data;
|
||||
using Jellyfin.Plugin.Reports.Api.Model;
|
||||
|
||||
namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
{
|
||||
@ -26,7 +28,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
/// <summary> Manager for library. </summary>
|
||||
protected readonly ILibraryManager _libraryManager;
|
||||
|
||||
protected Func<bool, string> GetBoolString = s => s == true ? "x" : "";
|
||||
protected Func<bool, string> GetBoolString = s => s == true ? "x" : string.Empty;
|
||||
|
||||
/// <summary> Gets the headers. </summary>
|
||||
/// <typeparam name="H"> Type of the header. </typeparam>
|
||||
@ -91,8 +93,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return string.Empty;
|
||||
return string.Format("{0:N}",
|
||||
GetGenre(name).Id);
|
||||
return GetGenre(name).Id.ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary> Gets the headers. </summary>
|
||||
@ -194,8 +195,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return string.Empty;
|
||||
return string.Format("{0:N}",
|
||||
GetPerson(name).Id);
|
||||
return GetPerson(name).Id.ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary> Gets report options. </summary>
|
||||
@ -302,8 +302,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return string.Empty;
|
||||
return string.Format("{0:N}",
|
||||
GetStudio(name).Id);
|
||||
return GetStudio(name).Id.ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary> Gets video resolution. </summary>
|
||||
@ -314,7 +313,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
var stream = GetStream(item,
|
||||
MediaStreamType.Video);
|
||||
if (stream != null && stream.Width != null)
|
||||
return string.Format("{0} * {1}",
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0} * {1}",
|
||||
stream.Width,
|
||||
stream.Height != null ? stream.Height.ToString() : "-");
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
@ -23,18 +24,18 @@ namespace Jellyfin.Plugin.Reports.Api.Common
|
||||
case ReportFieldType.Boolean:
|
||||
return value.ToString();
|
||||
case ReportFieldType.Date:
|
||||
return string.Format("{0:d}", value);
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0:d}", value);
|
||||
case ReportFieldType.Time:
|
||||
return string.Format("{0:t}", value);
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0:t}", value);
|
||||
case ReportFieldType.DateTime:
|
||||
return string.Format("{0:g}", value);
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0:g}", value);
|
||||
case ReportFieldType.Minutes:
|
||||
return string.Format("{0}mn", value);
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}mn", value);
|
||||
case ReportFieldType.Int:
|
||||
return string.Format("", value);
|
||||
return value.ToString();
|
||||
default:
|
||||
if (value is Guid)
|
||||
return string.Format("{0:N}", value);
|
||||
if (value is Guid guid)
|
||||
return guid.ToString("N", CultureInfo.InvariantCulture);
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ namespace Jellyfin.Plugin.Reports.Api.Data
|
||||
break;
|
||||
|
||||
case HeaderMetadata.Tracks:
|
||||
option.Column = (i, r) => this.GetObject<MusicAlbum, List<Audio>>(i, (x) => x.Tracks.ToList(), new List<Audio>()).Count();
|
||||
option.Column = (i, r) => this.GetObject<MusicAlbum, List<Audio>>(i, (x) => x.Tracks.ToList(), new List<Audio>()).Count;
|
||||
break;
|
||||
|
||||
case HeaderMetadata.Audio:
|
||||
@ -567,20 +567,18 @@ namespace Jellyfin.Plugin.Reports.Api.Data
|
||||
/// <returns> The row. </returns>
|
||||
private ReportRow GetRow(BaseItem item)
|
||||
{
|
||||
var video = item as Video;
|
||||
ReportRow rRow = new ReportRow
|
||||
return new ReportRow
|
||||
{
|
||||
Id = item.Id.ToString("N"),
|
||||
HasLockData = item.IsLocked,
|
||||
HasLocalTrailer = item.GetExtras(new[] { ExtraType.Trailer }).Any(),
|
||||
HasImageTagsPrimary = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Primary) > 0,
|
||||
HasImageTagsBackdrop = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Backdrop) > 0,
|
||||
HasImageTagsLogo = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Logo) > 0,
|
||||
HasImageTagsPrimary = item.ImageInfos != null && item.ImageInfos.Any(n => n.Type == ImageType.Primary),
|
||||
HasImageTagsBackdrop = item.ImageInfos != null && item.ImageInfos.Any(n => n.Type == ImageType.Backdrop),
|
||||
HasImageTagsLogo = item.ImageInfos != null && item.ImageInfos.Any(n => n.Type == ImageType.Logo),
|
||||
HasSpecials = item.GetExtras(BaseItem.DisplayExtraTypes).Any(),
|
||||
HasSubtitles = video != null ? video.HasSubtitles : false,
|
||||
HasSubtitles = item is Video video && video.HasSubtitles,
|
||||
RowType = ReportHelper.GetRowType(item.GetClientTypeName())
|
||||
};
|
||||
return rRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Jellyfin.Plugin.Reports.Api.Model;
|
||||
|
||||
@ -168,7 +169,7 @@ namespace Jellyfin.Plugin.Reports.Api.Data
|
||||
StringBuilder returnValue = new StringBuilder();
|
||||
returnValue.AppendLine("<table class='gridtable'>");
|
||||
returnValue.AppendLine("<tr>");
|
||||
returnValue.AppendLine(string.Join("", reportResult.Headers.Select(s => string.Format("<th>{0}</th>", s.Name)).ToArray()));
|
||||
returnValue.AppendLine(string.Join("", reportResult.Headers.Select(s => string.Format(CultureInfo.InvariantCulture, "<th>{0}</th>", s.Name)).ToArray()));
|
||||
returnValue.AppendLine("</tr>");
|
||||
if (reportResult.IsGrouped)
|
||||
foreach (ReportGroup group in reportResult.Groups)
|
||||
@ -202,7 +203,7 @@ namespace Jellyfin.Plugin.Reports.Api.Data
|
||||
ReportRow row)
|
||||
{
|
||||
returnValue.AppendLine("<tr>");
|
||||
returnValue.AppendLine(string.Join("", row.Columns.Select(s => string.Format("<td>{0}</td>", s.Name)).ToArray()));
|
||||
returnValue.AppendLine(string.Join("", row.Columns.Select(s => string.Format(CultureInfo.InvariantCulture, "<td>{0}</td>", s.Name)).ToArray()));
|
||||
returnValue.AppendLine("</tr>");
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ namespace Jellyfin.Plugin.Reports.Api
|
||||
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
return new VideoType[] { };
|
||||
return Array.Empty<VideoType>();
|
||||
}
|
||||
|
||||
return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray();
|
||||
@ -495,7 +495,7 @@ namespace Jellyfin.Plugin.Reports.Api
|
||||
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
return new ItemFilter[] { };
|
||||
return Array.Empty<ItemFilter>();
|
||||
}
|
||||
|
||||
return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray();
|
||||
@ -511,7 +511,7 @@ namespace Jellyfin.Plugin.Reports.Api
|
||||
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
return new ImageType[] { };
|
||||
return Array.Empty<ImageType>();
|
||||
}
|
||||
|
||||
return val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray();
|
||||
|
@ -123,7 +123,7 @@ namespace Jellyfin.Plugin.Reports.Api
|
||||
}
|
||||
|
||||
var filename = "ReportExport." + fileExtension;
|
||||
headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename);
|
||||
headers["Content-Disposition"] = string.Format(CultureInfo.InvariantCulture, "attachment; filename=\"{0}\"", filename);
|
||||
headers["Content-Encoding"] = "UTF-8";
|
||||
|
||||
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(new Guid(request.UserId)) : null;
|
||||
|
@ -5,6 +5,12 @@
|
||||
<AssemblyVersion>12.0.0.0</AssemblyVersion>
|
||||
<FileVersion>12.0.0.0</FileVersion>
|
||||
<RootNamespace>Jellyfin.Plugin.Reports</RootNamespace>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<AnalysisMode>Minimum</AnalysisMode>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
144
jellyfin.ruleset
Normal file
144
jellyfin.ruleset
Normal file
@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Rules for Jellyfin.Server" Description="Code analysis rules for Jellyfin.Server.csproj" ToolsVersion="14.0">
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
|
||||
<!-- error on SA1000: The keyword 'new' should be followed by a space -->
|
||||
<Rule Id="SA1000" Action="Error" />
|
||||
<!-- error on SA1001: Commas should not be preceded by whitespace -->
|
||||
<Rule Id="SA1001" Action="Error" />
|
||||
<!-- error on SA1117: The parameters should all be placed on the same line or each parameter should be placed on its own line -->
|
||||
<Rule Id="SA1117" Action="Error" />
|
||||
<!-- error on SA1142: Refer to tuple fields by name -->
|
||||
<Rule Id="SA1142" Action="Error" />
|
||||
<!-- error on SA1210: Using directives should be ordered alphabetically by the namespaces -->
|
||||
<Rule Id="SA1210" Action="Error" />
|
||||
<!-- error on SA1316: Tuple element names should use correct casing -->
|
||||
<Rule Id="SA1316" Action="Error" />
|
||||
<!-- error on SA1414: Tuple types in signatures should have element names -->
|
||||
<Rule Id="SA1414" Action="Error" />
|
||||
<!-- error on SA1518: File is required to end with a single newline character -->
|
||||
<Rule Id="SA1518" Action="Error" />
|
||||
<!-- error on SA1629: Documentation text should end with a period -->
|
||||
<Rule Id="SA1629" Action="Error" />
|
||||
|
||||
<!-- disable warning SA1009: Closing parenthesis should be followed by a space. -->
|
||||
<Rule Id="SA1009" Action="None" />
|
||||
<!-- disable warning SA1011: Closing square bracket should be followed by a space. -->
|
||||
<Rule Id="SA1011" Action="None" />
|
||||
<!-- disable warning SA1101: Prefix local calls with 'this.' -->
|
||||
<Rule Id="SA1101" Action="None" />
|
||||
<!-- disable warning SA1108: Block statements should not contain embedded comments -->
|
||||
<Rule Id="SA1108" Action="None" />
|
||||
<!-- disable warning SA1118: Parameter must not span multiple lines. -->
|
||||
<Rule Id="SA1118" Action="None" />
|
||||
<!-- disable warning SA1128:: Put constructor initializers on their own line -->
|
||||
<Rule Id="SA1128" Action="None" />
|
||||
<!-- disable warning SA1130: Use lambda syntax -->
|
||||
<Rule Id="SA1130" Action="None" />
|
||||
<!-- disable warning SA1200: 'using' directive must appear within a namespace declaration -->
|
||||
<Rule Id="SA1200" Action="None" />
|
||||
<!-- disable warning SA1202: 'public' members must come before 'private' members -->
|
||||
<Rule Id="SA1202" Action="None" />
|
||||
<!-- disable warning SA1204: Static members must appear before non-static members -->
|
||||
<Rule Id="SA1204" Action="None" />
|
||||
<!-- disable warning SA1309: Fields must not begin with an underscore -->
|
||||
<Rule Id="SA1309" Action="None" />
|
||||
<!-- disable warning SA1413: Use trailing comma in multi-line initializers -->
|
||||
<Rule Id="SA1413" Action="None" />
|
||||
<!-- disable warning SA1512: Single-line comments must not be followed by blank line -->
|
||||
<Rule Id="SA1512" Action="None" />
|
||||
<!-- disable warning SA1515: Single-line comment should be preceded by blank line -->
|
||||
<Rule Id="SA1515" Action="None" />
|
||||
<!-- disable warning SA1600: Elements should be documented -->
|
||||
<Rule Id="SA1600" Action="None" />
|
||||
<!-- disable warning SA1602: Enumeration items should be documented -->
|
||||
<Rule Id="SA1602" Action="None" />
|
||||
<!-- disable warning SA1633: The file header is missing or not located at the top of the file -->
|
||||
<Rule Id="SA1633" Action="None" />
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="Microsoft.CodeAnalysis.NetAnalyzers" RuleNamespace="Microsoft.Design">
|
||||
<!-- error on CA1063: Implement IDisposable correctly -->
|
||||
<Rule Id="CA1063" Action="Error" />
|
||||
<!-- error on CA1305: Specify IFormatProvider -->
|
||||
<Rule Id="CA1305" Action="Error" />
|
||||
<!-- error on CA1307: Specify StringComparison for clarity -->
|
||||
<Rule Id="CA1307" Action="Error" />
|
||||
<!-- error on CA1309: Use ordinal StringComparison -->
|
||||
<Rule Id="CA1309" 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 -->
|
||||
<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 CA1849: Call async methods when in an async method -->
|
||||
<Rule Id="CA1849" 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" />
|
||||
<!-- error on CA2254: Template should be a static expression -->
|
||||
<Rule Id="CA2254" Action="Error" />
|
||||
|
||||
<!-- disable warning CA1014: Mark assemblies with CLSCompliantAttribute -->
|
||||
<Rule Id="CA1014" Action="Info" />
|
||||
<!-- disable warning CA1024: Use properties where appropriate -->
|
||||
<Rule Id="CA1024" Action="Info" />
|
||||
<!-- disable warning CA1031: Do not catch general exception types -->
|
||||
<Rule Id="CA1031" Action="Info" />
|
||||
<!-- disable warning CA1032: Implement standard exception constructors -->
|
||||
<Rule Id="CA1032" Action="Info" />
|
||||
<!-- disable warning CA1040: Avoid empty interfaces -->
|
||||
<Rule Id="CA1040" Action="Info" />
|
||||
<!-- disable warning CA1062: Validate arguments of public methods -->
|
||||
<Rule Id="CA1062" Action="Info" />
|
||||
<!-- TODO: enable when false positives are fixed -->
|
||||
<!-- disable warning CA1508: Avoid dead conditional code -->
|
||||
<Rule Id="CA1508" Action="Info" />
|
||||
<!-- disable warning CA1716: Identifiers should not match keywords -->
|
||||
<Rule Id="CA1716" Action="Info" />
|
||||
<!-- disable warning CA1720: Identifiers should not contain type names -->
|
||||
<Rule Id="CA1720" Action="Info" />
|
||||
<!-- disable warning CA1724: Type names should not match namespaces -->
|
||||
<Rule Id="CA1724" Action="Info" />
|
||||
<!-- disable warning CA1805: Do not initialize unnecessarily -->
|
||||
<Rule Id="CA1805" Action="Info" />
|
||||
<!-- disable warning CA1812: internal class that is apparently never instantiated.
|
||||
If so, remove the code from the assembly.
|
||||
If this class is intended to contain only static members, make it static -->
|
||||
<Rule Id="CA1812" Action="Info" />
|
||||
<!-- disable warning CA1822: Member does not access instance data and can be marked as static -->
|
||||
<Rule Id="CA1822" Action="Info" />
|
||||
<!-- disable warning CA2000: Dispose objects before losing scope -->
|
||||
<Rule Id="CA2000" Action="Info" />
|
||||
<!-- disable warning CA2253: Named placeholders should not be numeric values -->
|
||||
<Rule Id="CA2253" Action="Info" />
|
||||
<!-- disable warning CA5394: Do not use insecure randomness -->
|
||||
<Rule Id="CA5394" Action="Info" />
|
||||
|
||||
<!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
|
||||
<Rule Id="CA1054" Action="None" />
|
||||
<!-- disable warning CA1055: URI return values should not be strings -->
|
||||
<Rule Id="CA1055" Action="None" />
|
||||
<!-- disable warning CA1056: URI properties should not be strings -->
|
||||
<Rule Id="CA1056" Action="None" />
|
||||
<!-- disable warning CA1303: Do not pass literals as localized parameters -->
|
||||
<Rule Id="CA1303" Action="None" />
|
||||
<!-- disable warning CA1308: Normalize strings to uppercase -->
|
||||
<Rule Id="CA1308" Action="None" />
|
||||
<!-- disable warning CA1848: Use the LoggerMessage delegates -->
|
||||
<Rule Id="CA1848" Action="None" />
|
||||
<!-- disable warning CA2101: Specify marshaling for P/Invoke string arguments -->
|
||||
<Rule Id="CA2101" Action="None" />
|
||||
<!-- disable warning CA2234: Pass System.Uri objects instead of strings -->
|
||||
<Rule Id="CA2234" Action="None" />
|
||||
</Rules>
|
||||
|
||||
<Rules AnalyzerId="Microsoft.CodeAnalysis.BannedApiAnalyzers" RuleNamespace="Microsoft.Design">
|
||||
<!-- error on RS0030: Do not used banned APIs -->
|
||||
<Rule Id="RS0030" Action="Error" />
|
||||
</Rules>
|
||||
</RuleSet>
|
Loading…
Reference in New Issue
Block a user