Add code analyzers to Jellyfin.Naming.Tests and fix resulting warnings

This commit is contained in:
aled 2020-05-14 18:59:10 +01:00
parent 2849d2b134
commit 3ff6e3ff65
8 changed files with 18 additions and 46 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<!-- ProjectGuid is only included as a requirement for SonarQube analysis --> <!-- ProjectGuid is only included as a requirement for SonarQube analysis -->
<PropertyGroup> <PropertyGroup>
@ -21,5 +21,15 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Emby.Naming\Emby.Naming.csproj" /> <ProjectReference Include="..\..\Emby.Naming\Emby.Naming.csproj" />
</ItemGroup> </ItemGroup>
<!-- Code Analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project> </Project>

View File

@ -6,8 +6,6 @@ namespace Jellyfin.Naming.Tests.TV
{ {
public class DailyEpisodeTests public class DailyEpisodeTests
{ {
[Theory] [Theory]
[InlineData(@"/server/anything_1996.11.14.mp4", "anything", 1996, 11, 14)] [InlineData(@"/server/anything_1996.11.14.mp4", "anything", 1996, 11, 14)]
[InlineData(@"/server/anything_1996-11-14.mp4", "anything", 1996, 11, 14)] [InlineData(@"/server/anything_1996-11-14.mp4", "anything", 1996, 11, 14)]

View File

@ -6,7 +6,6 @@ namespace Jellyfin.Naming.Tests.TV
{ {
public class EpisodeNumberWithoutSeasonTests public class EpisodeNumberWithoutSeasonTests
{ {
[Theory] [Theory]
[InlineData(8, @"The Simpsons/The Simpsons.S25E08.Steal this episode.mp4")] [InlineData(8, @"The Simpsons/The Simpsons.S25E08.Steal this episode.mp4")]
[InlineData(2, @"The Simpsons/The Simpsons - 02 - Ep Name.avi")] [InlineData(2, @"The Simpsons/The Simpsons - 02 - Ep Name.avi")]

View File

@ -1,4 +1,4 @@
using Emby.Naming.Common; using Emby.Naming.Common;
using Emby.Naming.TV; using Emby.Naming.TV;
using Xunit; using Xunit;
@ -35,7 +35,6 @@ namespace Jellyfin.Naming.Tests.TV
// TODO: [InlineData("Watchmen (2019)/Watchmen 1x03 [WEBDL-720p][EAC3 5.1][h264][-TBS] - She Was Killed by Space Junk.mkv", "Watchmen (2019)", 1, 3)] // TODO: [InlineData("Watchmen (2019)/Watchmen 1x03 [WEBDL-720p][EAC3 5.1][h264][-TBS] - She Was Killed by Space Junk.mkv", "Watchmen (2019)", 1, 3)]
// TODO: [InlineData("/The.Legend.of.Condor.Heroes.2017.V2.web-dl.1080p.h264.aac-hdctv/The.Legend.of.Condor.Heroes.2017.E07.V2.web-dl.1080p.h264.aac-hdctv.mkv", "The Legend of Condor Heroes 2017", 1, 7)] // TODO: [InlineData("/The.Legend.of.Condor.Heroes.2017.V2.web-dl.1080p.h264.aac-hdctv/The.Legend.of.Condor.Heroes.2017.E07.V2.web-dl.1080p.h264.aac-hdctv.mkv", "The Legend of Condor Heroes 2017", 1, 7)]
public void ParseEpisodesCorrectly(string path, string name, int season, int episode) public void ParseEpisodesCorrectly(string path, string name, int season, int episode)
{ {
NamingOptions o = new NamingOptions(); NamingOptions o = new NamingOptions();
EpisodePathParser p = new EpisodePathParser(o); EpisodePathParser p = new EpisodePathParser(o);

View File

@ -28,7 +28,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -53,7 +52,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -76,7 +74,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -104,7 +101,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(7, result.Count); Assert.Equal(7, result.Count);
@ -134,7 +130,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -165,7 +160,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(9, result.Count); Assert.Equal(9, result.Count);
@ -192,7 +186,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(5, result.Count); Assert.Equal(5, result.Count);
@ -221,7 +214,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(5, result.Count); Assert.Equal(5, result.Count);
@ -251,7 +243,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -284,7 +275,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -311,7 +301,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(2, result.Count); Assert.Equal(2, result.Count);
@ -340,7 +329,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -372,7 +360,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(5, result.Count); Assert.Equal(5, result.Count);
@ -396,7 +383,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -422,7 +408,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);

View File

@ -368,11 +368,11 @@ namespace Jellyfin.Naming.Tests.Video
{ {
var files = new[] var files = new[]
{ {
new FileSystemMetadata{FullName = "Bad Boys (2006) part1.mkv", IsDirectory = false}, new FileSystemMetadata { FullName = "Bad Boys (2006) part1.mkv", IsDirectory = false },
new FileSystemMetadata{FullName = "Bad Boys (2006) part2.mkv", IsDirectory = false}, new FileSystemMetadata { FullName = "Bad Boys (2006) part2.mkv", IsDirectory = false },
new FileSystemMetadata{FullName = "300 (2006) part2", IsDirectory = true}, new FileSystemMetadata { FullName = "300 (2006) part2", IsDirectory = true },
new FileSystemMetadata{FullName = "300 (2006) part3", IsDirectory = true}, new FileSystemMetadata { FullName = "300 (2006) part3", IsDirectory = true },
new FileSystemMetadata{FullName = "300 (2006) part1", IsDirectory = true} new FileSystemMetadata { FullName = "300 (2006) part1", IsDirectory = true }
}; };
var resolver = GetResolver(); var resolver = GetResolver();

View File

@ -9,6 +9,7 @@ namespace Jellyfin.Naming.Tests.Video
public class VideoListResolverTests public class VideoListResolverTests
{ {
private readonly NamingOptions _namingOptions = new NamingOptions(); private readonly NamingOptions _namingOptions = new NamingOptions();
// FIXME // FIXME
// [Fact] // [Fact]
private void TestStackAndExtras() private void TestStackAndExtras()
@ -45,7 +46,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(5, result.Count); Assert.Equal(5, result.Count);
@ -74,7 +74,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -95,7 +94,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -116,7 +114,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -138,7 +135,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -159,7 +155,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -184,7 +179,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(5, result.Count); Assert.Equal(5, result.Count);
@ -205,7 +199,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = true, IsDirectory = true,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -227,7 +220,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = true, IsDirectory = true,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(2, result.Count); Assert.Equal(2, result.Count);
@ -249,7 +241,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -271,7 +262,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -294,7 +284,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -317,7 +306,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(2, result.Count); Assert.Equal(2, result.Count);
@ -337,7 +325,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -357,7 +344,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -378,7 +364,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -399,7 +384,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);
@ -422,7 +406,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Equal(4, result.Count); Assert.Equal(4, result.Count);
@ -443,7 +426,6 @@ namespace Jellyfin.Naming.Tests.Video
{ {
IsDirectory = false, IsDirectory = false,
FullName = i FullName = i
}).ToList()).ToList(); }).ToList()).ToList();
Assert.Single(result); Assert.Single(result);

View File

@ -176,7 +176,6 @@ namespace Jellyfin.Naming.Tests.Video
}; };
} }
[Theory] [Theory]
[MemberData(nameof(GetResolveFileTestData))] [MemberData(nameof(GetResolveFileTestData))]
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult) public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult)