From 09e5c3ba6988bb9fc13b197d282f8647c727708b Mon Sep 17 00:00:00 2001 From: SenorSmartyPants Date: Tue, 14 Mar 2023 16:39:22 -0500 Subject: [PATCH] Code review: Count() -> Count and comments capitalization --- Emby.Naming/Common/NamingOptions.cs | 2 +- Emby.Naming/Video/VideoListResolver.cs | 22 +++++++++---------- MediaBrowser.Controller/Entities/BaseItem.cs | 4 ++-- .../Video/VideoListResolverTests.cs | 3 --- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index 1e953848e8..e62da6e8e0 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -728,7 +728,7 @@ namespace Emby.Naming.Common VideoVersionExpressions = new[] { - // get filename before final space-dash-space + // Get filename before final space-dash-space @"^(?.*?)(?:\s-\s(?!.*\s-\s)(.*))?$" }; diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index 6812645c15..e95fd25742 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -89,7 +89,7 @@ namespace Emby.Naming.Video info.Year = info.Files[0].Year; if (info.Year is null) { - // parse name for year info. Episodes don't get parsed up to this point for year info + // Parse name for year info. Episodes don't get parsed up to this point for year info. var info2 = VideoResolver.Resolve(media.Path, media.IsDirectory, namingOptions, parseName); info.Year = info2?.Year; } @@ -139,8 +139,8 @@ namespace Emby.Naming.Video continue; } - // don't merge stacked episodes - if (video.Files.Count() == 1 && IsEligibleForMultiVersion(folderName, video.Files[0].Path, namingOptions, collectionType)) + // Don't merge stacked episodes + if (video.Files.Count == 1 && IsEligibleForMultiVersion(folderName, video.Files[0].Path, namingOptions, collectionType)) { mergeable.Add(video); } @@ -164,12 +164,12 @@ namespace Emby.Naming.Video list.Add(OrganizeAlternateVersions(grouping.ToList(), grouping.Key.AsSpan(), primary)); } } - else if (mergeable.Count() > 0) + else if (mergeable.Count > 0) { list.Add(OrganizeAlternateVersions(mergeable, folderName, primary)); } - // add non mergeables back in + // Add non mergeables back in list.AddRange(notMergeable); list.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal)); @@ -185,7 +185,7 @@ namespace Emby.Naming.Video } var alternateVersions = new List(); - if (grouping.Count() > 1) + if (grouping.Count > 1) { // groups resolution based into one, and all other names var groups = grouping.GroupBy(x => ResolutionRegex().IsMatch(x.Files[0].FileNameWithoutExtension)); @@ -235,7 +235,7 @@ namespace Emby.Naming.Video if (collectionType.Equals(CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) { - // episodes are always eligible to be grouped + // Episodes are always eligible to be grouped return true; } @@ -264,13 +264,13 @@ namespace Emby.Naming.Video private static string EpisodeGrouper(string testFilePath, NamingOptions namingOptions, ReadOnlySpan collectionType) { - // grouper for tv shows/episodes should be everything before space-dash-space + // Grouper for tv shows/episodes should be everything before space-dash-space var resolver = new EpisodeResolver(namingOptions); EpisodeInfo? episodeInfo = resolver.Resolve(testFilePath, false); ReadOnlySpan seriesName = episodeInfo!.SeriesName; var filename = Path.GetFileNameWithoutExtension(testFilePath); - // start with grouping by filename + // Start with grouping by filename string g = filename; for (var i = 0; i < namingOptions.VideoVersionRegexes.Length; i++) { @@ -282,13 +282,13 @@ namespace Emby.Naming.Video } g = match.Groups["filename"].Value; - // clean the filename + // Clean the filename if (VideoResolver.TryCleanString(g, namingOptions, out string newName)) { g = newName; } - // never group episodes under series name + // Never group episodes under series name if (MemoryExtensions.Equals(g.AsSpan(), seriesName, StringComparison.OrdinalIgnoreCase)) { g = filename; diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index b552a2b0f8..11bb1b2da2 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1186,8 +1186,8 @@ namespace MediaBrowser.Controller.Entities if (fileName == displayName) { - // file does not start with parent folder name. This must be an episode in a mixed directory - // get string after last dash - this is the version name + // File does not start with parent folder name. This must be an episode in a mixed directory + // Get string after last dash - this is the version name displayName = fileName.Substring(fileName.LastIndexOf('-') + 1).TrimStart(new char[] { ' ', '-' }); } diff --git a/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs b/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs index eff57721b7..3a8be1447d 100644 --- a/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs +++ b/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs @@ -69,7 +69,6 @@ namespace Jellyfin.Naming.Tests.Video [Fact] public void TestTVStackAndVersions() { - // No stacking here because there is no part/disc/etc var files = new[] { @"/TV/Grey's Anatomy (2005)/Grey's Anatomy (2005) - s01e01 CD1.avi", @@ -99,7 +98,6 @@ namespace Jellyfin.Naming.Tests.Video [Fact] public void TestTVStackAndVersionsNoFirstDash() { - // No stacking here because there is no part/disc/etc var files = new[] { @"/TV/Grey's Anatomy (2005)/Grey's Anatomy (2005) s01e01 - pt1.avi", @@ -129,7 +127,6 @@ namespace Jellyfin.Naming.Tests.Video [Fact] public void TestTVStack() { - // No stacking here because there is no part/disc/etc var files = new[] { @"/TV/Doctor Who/Season 21/Doctor Who 21x11 - Resurrection of the Daleks - Part 1.mkv",