From 8e8a6207a5cf7c0a29d10b6a3ed724e66d88881a Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Sun, 3 Mar 2024 21:46:52 -0500 Subject: [PATCH] Update StyleCop and address warnings --- .gitignore | 4 ++++ .../Analyzers/ChapterAnalyzer.cs | 2 +- .../Analyzers/ChromaprintAnalyzer.cs | 4 ++-- .../ConfusedPolarBear.Plugin.IntroSkipper.csproj | 8 ++------ .../GlobalSuppressions.cs | 10 ++++++++++ ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs diff --git a/.gitignore b/.gitignore index 295855b..6908286 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ BenchmarkDotNet.Artifacts/ # Ignore pre compiled web interface docker/dist + +# Visual Studio +.vs/ +UpgradeLog*.htm diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs index b22e428..763d461 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChapterAnalyzer.cs @@ -7,8 +7,8 @@ using System.Globalization; using System.Linq; using System.Text.RegularExpressions; using System.Threading; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Entities; +using Microsoft.Extensions.Logging; /// /// Chapter name analyzer. diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs index c230c1b..2a03321 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/ChromaprintAnalyzer.cs @@ -275,10 +275,10 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer { var modifiedPoint = (uint)(originalPoint + i); - if (rhsIndex.ContainsKey(modifiedPoint)) + if (rhsIndex.TryGetValue(modifiedPoint, out var value)) { var lhsFirst = (int)lhsIndex[originalPoint]; - var rhsFirst = (int)rhsIndex[modifiedPoint]; + var rhsFirst = (int)value; indexShifts.Add(rhsFirst - lhsFirst); } } diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj index 3970a4e..1f3c386 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj @@ -1,5 +1,4 @@ - net6.0 ConfusedPolarBear.Plugin.IntroSkipper @@ -11,15 +10,13 @@ AllEnabledByDefault ../jellyfin.ruleset - - + - @@ -27,5 +24,4 @@ - - + \ No newline at end of file diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs b/ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs new file mode 100644 index 0000000..2967ca7 --- /dev/null +++ b/ConfusedPolarBear.Plugin.IntroSkipper/GlobalSuppressions.cs @@ -0,0 +1,10 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Legacy TODO", Scope = "type", Target = "~T:ConfusedPolarBear.Plugin.IntroSkipper.WarningManager")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Legacy TODO", Scope = "type", Target = "~T:ConfusedPolarBear.Plugin.IntroSkipper.IntroWithMetadata")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Legacy TODO", Scope = "type", Target = "~T:ConfusedPolarBear.Plugin.IntroSkipper.TimeRangeHelpers")] diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs index 7f57af8..5fd0b8d 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Plugin.cs @@ -331,7 +331,7 @@ public class Plugin : BasePlugin, IHasWebPages private void InjectSkipButton(string indexPath) { // Parts of this code are based off of JellyScrub's script injection code. - // https://github.com/nicknsy/jellyscrub/blob/4ce806f602988a662cfe3cdbaac35ee8046b7ec4/Nick.Plugin.Jellyscrub/JellyscrubPlugin.cs + // https://github.com/nicknsy/jellyscrub/blob/main/Nick.Plugin.Jellyscrub/JellyscrubPlugin.cs#L38 _logger.LogDebug("Reading index.html from {Path}", indexPath); var contents = File.ReadAllText(indexPath);