Use Length/Count property instead of Count() method to prevent enumerating
This commit is contained in:
parent
4fe9daec03
commit
e805f61450
|
@ -194,7 +194,6 @@ dotnet_diagnostic.CA1819.severity = suggestion
|
||||||
dotnet_diagnostic.CA1822.severity = suggestion
|
dotnet_diagnostic.CA1822.severity = suggestion
|
||||||
dotnet_diagnostic.CA1823.severity = suggestion
|
dotnet_diagnostic.CA1823.severity = suggestion
|
||||||
dotnet_diagnostic.CA1824.severity = suggestion
|
dotnet_diagnostic.CA1824.severity = suggestion
|
||||||
dotnet_diagnostic.CA1829.severity = suggestion
|
|
||||||
dotnet_diagnostic.CA1834.severity = suggestion
|
dotnet_diagnostic.CA1834.severity = suggestion
|
||||||
dotnet_diagnostic.CA1839.severity = suggestion
|
dotnet_diagnostic.CA1839.severity = suggestion
|
||||||
dotnet_diagnostic.CA1840.severity = suggestion
|
dotnet_diagnostic.CA1840.severity = suggestion
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace NzbDrone.Core.Test.Extras.Others
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(1);
|
results.Count.Should().Be(1);
|
||||||
|
|
||||||
results[0].RelativePath.AsOsAgnostic().PathEquals(Path.Combine("Season 1", expectedOutputPath).AsOsAgnostic()).Should().Be(true);
|
results[0].RelativePath.AsOsAgnostic().PathEquals(Path.Combine("Season 1", expectedOutputPath).AsOsAgnostic()).Should().Be(true);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.Extras.Others
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(1);
|
results.Count.Should().Be(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(0);
|
results.Count.Should().Be(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(1);
|
results.Count.Should().Be(1);
|
||||||
|
|
||||||
results[0].RelativePath.AsOsAgnostic().PathEquals(Path.Combine("Season 1", expectedOutputPath).AsOsAgnostic()).Should().Be(true);
|
results[0].RelativePath.AsOsAgnostic().PathEquals(Path.Combine("Season 1", expectedOutputPath).AsOsAgnostic()).Should().Be(true);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(expectedOutputs.Length);
|
results.Count.Should().Be(expectedOutputs.Length);
|
||||||
|
|
||||||
for (int i = 0; i < expectedOutputs.Length; i++)
|
for (int i = 0; i < expectedOutputs.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, files, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(expectedOutputs.Length);
|
results.Count.Should().Be(expectedOutputs.Length);
|
||||||
|
|
||||||
for (int i = 0; i < expectedOutputs.Length; i++)
|
for (int i = 0; i < expectedOutputs.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, new List<string> { subtitleFile }, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, new List<string> { subtitleFile }, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(1);
|
results.Count.Should().Be(1);
|
||||||
|
|
||||||
results[0].RelativePath.AsOsAgnostic().PathEquals(Path.Combine("Season 1", expectedOutputPath).AsOsAgnostic()).Should().Be(true);
|
results[0].RelativePath.AsOsAgnostic().PathEquals(Path.Combine("Season 1", expectedOutputPath).AsOsAgnostic()).Should().Be(true);
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ namespace NzbDrone.Core.Test.Extras.Subtitles
|
||||||
|
|
||||||
var results = Subject.ImportFiles(_localEpisode, _episodeFile, new List<string> { subtitleFile }, true).ToList();
|
var results = Subject.ImportFiles(_localEpisode, _episodeFile, new List<string> { subtitleFile }, true).ToList();
|
||||||
|
|
||||||
results.Count().Should().Be(0);
|
results.Count.Should().Be(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeServiceTests
|
||||||
|
|
||||||
private void GivenEpisodesWithTitles(params string[] titles)
|
private void GivenEpisodesWithTitles(params string[] titles)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < titles.Count(); i++)
|
for (int i = 0; i < titles.Length; i++)
|
||||||
{
|
{
|
||||||
_episodes[i].Title = titles[i];
|
_episodes[i].Title = titles[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
|
|
||||||
// Ensure that this is either the first episode
|
// Ensure that this is either the first episode
|
||||||
// or is the last episode in a season that has 10 or more episodes
|
// or is the last episode in a season that has 10 or more episodes
|
||||||
if (seasonEpisodes.First().Id == firstEpisode.Id || (seasonEpisodes.Count() >= 10 && seasonEpisodes.Last().Id == firstEpisode.Id))
|
if (seasonEpisodes.First().Id == firstEpisode.Id || (seasonEpisodes.Count >= 10 && seasonEpisodes.Last().Id == firstEpisode.Id))
|
||||||
{
|
{
|
||||||
_logger.Debug("Possible double episode, doubling allowed size.");
|
_logger.Debug("Possible double episode, doubling allowed size.");
|
||||||
maxSize = maxSize * 2;
|
maxSize = maxSize * 2;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||||
// test against episodes of the same season in the current search, and make sure they have an air date
|
// test against episodes of the same season in the current search, and make sure they have an air date
|
||||||
var subset = searchCriteria.Episodes.Where(e => e.AirDateUtc.HasValue && e.SeasonNumber == subject.Episodes.First().SeasonNumber).ToList();
|
var subset = searchCriteria.Episodes.Where(e => e.AirDateUtc.HasValue && e.SeasonNumber == subject.Episodes.First().SeasonNumber).ToList();
|
||||||
|
|
||||||
if (subset.Count() > 0 && subset.Max(e => e.AirDateUtc).Value.Before(DateTime.UtcNow - TimeSpan.FromDays(subject.Release.SeasonSearchMaximumSingleEpisodeAge)))
|
if (subset.Count > 0 && subset.Max(e => e.AirDateUtc).Value.Before(DateTime.UtcNow - TimeSpan.FromDays(subject.Release.SeasonSearchMaximumSingleEpisodeAge)))
|
||||||
{
|
{
|
||||||
_logger.Debug("Release {0}: last episode in this season aired more than {1} days ago, season pack required.", subject.Release.Title, subject.Release.SeasonSearchMaximumSingleEpisodeAge);
|
_logger.Debug("Release {0}: last episode in this season aired more than {1} days ago, season pack required.", subject.Release.Title, subject.Release.SeasonSearchMaximumSingleEpisodeAge);
|
||||||
return Decision.Reject("Last episode in this season aired more than {0} days ago, season pack required.", subject.Release.SeasonSearchMaximumSingleEpisodeAge);
|
return Decision.Reject("Last episode in this season aired more than {0} days ago, season pack required.", subject.Release.SeasonSearchMaximumSingleEpisodeAge);
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
|
||||||
{
|
{
|
||||||
var split = reader.Value.ToString().Split(':').Select(int.Parse).ToArray();
|
var split = reader.Value.ToString().Split(':').Select(int.Parse).ToArray();
|
||||||
|
|
||||||
switch (split.Count())
|
switch (split.Length)
|
||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
return new TimeSpan((split[0] * 24) + split[1], split[2], split[3]);
|
return new TimeSpan((split[0] * 24) + split[1], split[2], split[3]);
|
||||||
|
|
|
@ -117,9 +117,9 @@ namespace NzbDrone.Core.Download.Pending
|
||||||
_logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteEpisode, reason);
|
_logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteEpisode, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchingReports.Count() > 1)
|
if (matchingReports.Count > 1)
|
||||||
{
|
{
|
||||||
_logger.Debug("The release {0} had {1} duplicate pending, removing duplicates.", decision.RemoteEpisode, matchingReports.Count() - 1);
|
_logger.Debug("The release {0} had {1} duplicate pending, removing duplicates.", decision.RemoteEpisode, matchingReports.Count - 1);
|
||||||
|
|
||||||
foreach (var duplicate in matchingReports.Skip(1))
|
foreach (var duplicate in matchingReports.Skip(1))
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace NzbDrone.Core.Extras.Subtitles
|
||||||
.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
|
.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (videoFiles.Count() > 2)
|
if (videoFiles.Count > 2)
|
||||||
{
|
{
|
||||||
return importedFiles;
|
return importedFiles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
|
|
||||||
var seriesText = deletedSeries.Select(s => $"{s.Title} (tvdbid {s.TvdbId})").Join(", ");
|
var seriesText = deletedSeries.Select(s => $"{s.Title} (tvdbid {s.TvdbId})").Join(", ");
|
||||||
|
|
||||||
if (deletedSeries.Count() == 1)
|
if (deletedSeries.Count == 1)
|
||||||
{
|
{
|
||||||
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Series {seriesText} was removed from TheTVDB", "#series-removed-from-thetvdb");
|
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Series {seriesText} was removed from TheTVDB", "#series-removed-from-thetvdb");
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
|
||||||
releases = ParseResponse(parser, response);
|
releases = ParseResponse(parser, response);
|
||||||
ValidateReleases(releases, indexerSettings);
|
ValidateReleases(releases, indexerSettings);
|
||||||
|
|
||||||
if (releases.Count(r => r.Size >= ValidSizeThreshold) > releases.Count() / 2)
|
if (releases.Count(r => r.Size >= ValidSizeThreshold) > releases.Length / 2)
|
||||||
{
|
{
|
||||||
if (releases.Any(r => r.Size < ValidSizeThreshold))
|
if (releases.Any(r => r.Size < ValidSizeThreshold))
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace NzbDrone.Core.Jobs
|
||||||
|
|
||||||
var currentTasks = _scheduledTaskRepository.All().ToList();
|
var currentTasks = _scheduledTaskRepository.All().ToList();
|
||||||
|
|
||||||
_logger.Trace("Initializing jobs. Available: {0} Existing: {1}", defaultTasks.Count(), currentTasks.Count());
|
_logger.Trace("Initializing jobs. Available: {0} Existing: {1}", defaultTasks.Count, currentTasks.Count);
|
||||||
|
|
||||||
foreach (var job in currentTasks)
|
foreach (var job in currentTasks)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
var newFiles = filterExistingFiles ? _mediaFileService.FilterExistingFiles(videoFiles.ToList(), series) : videoFiles.ToList();
|
var newFiles = filterExistingFiles ? _mediaFileService.FilterExistingFiles(videoFiles.ToList(), series) : videoFiles.ToList();
|
||||||
|
|
||||||
_logger.Debug("Analyzing {0}/{1} files.", newFiles.Count, videoFiles.Count());
|
_logger.Debug("Analyzing {0}/{1} files.", newFiles.Count, videoFiles.Count);
|
||||||
|
|
||||||
ParsedEpisodeInfo downloadClientItemInfo = null;
|
ParsedEpisodeInfo downloadClientItemInfo = null;
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
|
||||||
// If the series is unknown for the directory and there are more than 100 files in the folder don't process the items before returning.
|
// If the series is unknown for the directory and there are more than 100 files in the folder don't process the items before returning.
|
||||||
var files = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder, false));
|
var files = _diskScanService.FilterPaths(rootFolder, _diskScanService.GetVideoFiles(baseFolder, false));
|
||||||
|
|
||||||
if (files.Count() > 100)
|
if (files.Count > 100)
|
||||||
{
|
{
|
||||||
_logger.Warn("Unable to determine series from folder name and found more than 100 files. Skipping parsing");
|
_logger.Warn("Unable to determine series from folder name and found more than 100 files. Skipping parsing");
|
||||||
return ProcessDownloadDirectory(rootFolder, files);
|
return ProcessDownloadDirectory(rootFolder, files);
|
||||||
|
|
Loading…
Reference in New Issue