Code review: Count() -> Count and comments capitalization

This commit is contained in:
SenorSmartyPants 2023-03-14 16:39:22 -05:00
parent 9016fec892
commit 09e5c3ba69
4 changed files with 14 additions and 17 deletions

View file

@ -728,7 +728,7 @@ namespace Emby.Naming.Common
VideoVersionExpressions = new[] VideoVersionExpressions = new[]
{ {
// get filename before final space-dash-space // Get filename before final space-dash-space
@"^(?<filename>.*?)(?:\s-\s(?!.*\s-\s)(.*))?$" @"^(?<filename>.*?)(?:\s-\s(?!.*\s-\s)(.*))?$"
}; };

View file

@ -89,7 +89,7 @@ namespace Emby.Naming.Video
info.Year = info.Files[0].Year; info.Year = info.Files[0].Year;
if (info.Year is null) 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); var info2 = VideoResolver.Resolve(media.Path, media.IsDirectory, namingOptions, parseName);
info.Year = info2?.Year; info.Year = info2?.Year;
} }
@ -139,8 +139,8 @@ namespace Emby.Naming.Video
continue; continue;
} }
// don't merge stacked episodes // Don't merge stacked episodes
if (video.Files.Count() == 1 && IsEligibleForMultiVersion(folderName, video.Files[0].Path, namingOptions, collectionType)) if (video.Files.Count == 1 && IsEligibleForMultiVersion(folderName, video.Files[0].Path, namingOptions, collectionType))
{ {
mergeable.Add(video); mergeable.Add(video);
} }
@ -164,12 +164,12 @@ namespace Emby.Naming.Video
list.Add(OrganizeAlternateVersions(grouping.ToList(), grouping.Key.AsSpan(), primary)); 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)); list.Add(OrganizeAlternateVersions(mergeable, folderName, primary));
} }
// add non mergeables back in // Add non mergeables back in
list.AddRange(notMergeable); list.AddRange(notMergeable);
list.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal)); list.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal));
@ -185,7 +185,7 @@ namespace Emby.Naming.Video
} }
var alternateVersions = new List<VideoInfo>(); var alternateVersions = new List<VideoInfo>();
if (grouping.Count() > 1) if (grouping.Count > 1)
{ {
// groups resolution based into one, and all other names // groups resolution based into one, and all other names
var groups = grouping.GroupBy(x => ResolutionRegex().IsMatch(x.Files[0].FileNameWithoutExtension)); 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)) if (collectionType.Equals(CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{ {
// episodes are always eligible to be grouped // Episodes are always eligible to be grouped
return true; return true;
} }
@ -264,13 +264,13 @@ namespace Emby.Naming.Video
private static string EpisodeGrouper(string testFilePath, NamingOptions namingOptions, ReadOnlySpan<char> collectionType) private static string EpisodeGrouper(string testFilePath, NamingOptions namingOptions, ReadOnlySpan<char> 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); var resolver = new EpisodeResolver(namingOptions);
EpisodeInfo? episodeInfo = resolver.Resolve(testFilePath, false); EpisodeInfo? episodeInfo = resolver.Resolve(testFilePath, false);
ReadOnlySpan<char> seriesName = episodeInfo!.SeriesName; ReadOnlySpan<char> seriesName = episodeInfo!.SeriesName;
var filename = Path.GetFileNameWithoutExtension(testFilePath); var filename = Path.GetFileNameWithoutExtension(testFilePath);
// start with grouping by filename // Start with grouping by filename
string g = filename; string g = filename;
for (var i = 0; i < namingOptions.VideoVersionRegexes.Length; i++) for (var i = 0; i < namingOptions.VideoVersionRegexes.Length; i++)
{ {
@ -282,13 +282,13 @@ namespace Emby.Naming.Video
} }
g = match.Groups["filename"].Value; g = match.Groups["filename"].Value;
// clean the filename // Clean the filename
if (VideoResolver.TryCleanString(g, namingOptions, out string newName)) if (VideoResolver.TryCleanString(g, namingOptions, out string newName))
{ {
g = newName; g = newName;
} }
// never group episodes under series name // Never group episodes under series name
if (MemoryExtensions.Equals(g.AsSpan(), seriesName, StringComparison.OrdinalIgnoreCase)) if (MemoryExtensions.Equals(g.AsSpan(), seriesName, StringComparison.OrdinalIgnoreCase))
{ {
g = filename; g = filename;

View file

@ -1186,8 +1186,8 @@ namespace MediaBrowser.Controller.Entities
if (fileName == displayName) if (fileName == displayName)
{ {
// file does not start with parent folder name. This must be an episode in a mixed directory // 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 // Get string after last dash - this is the version name
displayName = fileName.Substring(fileName.LastIndexOf('-') + 1).TrimStart(new char[] { ' ', '-' }); displayName = fileName.Substring(fileName.LastIndexOf('-') + 1).TrimStart(new char[] { ' ', '-' });
} }

View file

@ -69,7 +69,6 @@ namespace Jellyfin.Naming.Tests.Video
[Fact] [Fact]
public void TestTVStackAndVersions() public void TestTVStackAndVersions()
{ {
// No stacking here because there is no part/disc/etc
var files = new[] var files = new[]
{ {
@"/TV/Grey's Anatomy (2005)/Grey's Anatomy (2005) - s01e01 CD1.avi", @"/TV/Grey's Anatomy (2005)/Grey's Anatomy (2005) - s01e01 CD1.avi",
@ -99,7 +98,6 @@ namespace Jellyfin.Naming.Tests.Video
[Fact] [Fact]
public void TestTVStackAndVersionsNoFirstDash() public void TestTVStackAndVersionsNoFirstDash()
{ {
// No stacking here because there is no part/disc/etc
var files = new[] var files = new[]
{ {
@"/TV/Grey's Anatomy (2005)/Grey's Anatomy (2005) s01e01 - pt1.avi", @"/TV/Grey's Anatomy (2005)/Grey's Anatomy (2005) s01e01 - pt1.avi",
@ -129,7 +127,6 @@ namespace Jellyfin.Naming.Tests.Video
[Fact] [Fact]
public void TestTVStack() public void TestTVStack()
{ {
// No stacking here because there is no part/disc/etc
var files = new[] var files = new[]
{ {
@"/TV/Doctor Who/Season 21/Doctor Who 21x11 - Resurrection of the Daleks - Part 1.mkv", @"/TV/Doctor Who/Season 21/Doctor Who 21x11 - Resurrection of the Daleks - Part 1.mkv",