refactor: Use collection expressions in a few places

pull/231/head
Robert Dailey 2 months ago
parent 9bd66d0e1e
commit 75a87707bf

@ -2,7 +2,7 @@ namespace Recyclarr.Cli.Pipelines.MediaNaming.PipelinePhases.Config;
public class NamingFormatLookup public class NamingFormatLookup
{ {
private readonly List<InvalidNamingConfig> _errors = new(); private readonly List<InvalidNamingConfig> _errors = [];
public IReadOnlyCollection<InvalidNamingConfig> Errors => _errors; public IReadOnlyCollection<InvalidNamingConfig> Errors => _errors;
public string? ObtainFormat( public string? ObtainFormat(

@ -7,11 +7,11 @@ public class GitRepositoryFactory(ILogger log, IGitPath gitPath) : IGitRepositor
{ {
// A few hand-picked files that should exist in a .git directory. // A few hand-picked files that should exist in a .git directory.
private static readonly string[] ValidGitPaths = private static readonly string[] ValidGitPaths =
{ [
".git/config", ".git/config",
".git/index", ".git/index",
".git/HEAD" ".git/HEAD"
}; ];
public async Task<IGitRepository> CreateAndCloneIfNeeded( public async Task<IGitRepository> CreateAndCloneIfNeeded(
Uri repoUrl, Uri repoUrl,

@ -7,7 +7,7 @@ namespace Recyclarr.Yaml.YamlDotNet;
public sealed class SyntaxErrorHelper : INodeTypeResolver public sealed class SyntaxErrorHelper : INodeTypeResolver
{ {
private static readonly string[] CollectionKeywords = {"Collection", "List"}; private static readonly string[] CollectionKeywords = ["Collection", "List"];
public bool Resolve(NodeEvent? nodeEvent, ref Type currentType) public bool Resolve(NodeEvent? nodeEvent, ref Type currentType)
{ {

@ -35,7 +35,7 @@ public class CompositionRootTest
.Select(x => x.ServiceType) .Select(x => x.ServiceType)
.Distinct() .Distinct()
.Where(x => x.FullName == null || !x.FullName.StartsWith("Autofac.")) .Where(x => x.FullName == null || !x.FullName.StartsWith("Autofac."))
.Select(x => new TestCaseParameters(new object[] {container, x}) {TestName = x.FullName}) .Select(x => new TestCaseParameters([container, x]) {TestName = x.FullName})
.GetEnumerator(); .GetEnumerator();
} }
} }

@ -10,12 +10,12 @@ public class ConfigurationFinderTest
{ {
private static IFileInfo[] GetYamlPaths(IAppPaths paths) private static IFileInfo[] GetYamlPaths(IAppPaths paths)
{ {
return new[] return
{ [
paths.AppDataDirectory.File("recyclarr.yml"), paths.AppDataDirectory.File("recyclarr.yml"),
paths.ConfigsDirectory.File("b.yml"), paths.ConfigsDirectory.File("b.yml"),
paths.ConfigsDirectory.File("c.yaml") paths.ConfigsDirectory.File("c.yaml")
}; ];
} }
[Test, AutoMockData] [Test, AutoMockData]

@ -6,7 +6,7 @@ namespace Recyclarr.Tests.TrashGuide.QualitySize;
public class QualityItemTest public class QualityItemTest
{ {
private static readonly object[] MaxTestValues = private static readonly object[] MaxTestValues =
{ [
new object?[] {100m, 100m, false}, new object?[] {100m, 100m, false},
new object?[] {100m, 101m, true}, new object?[] {100m, 101m, true},
new object?[] {100m, 98m, true}, new object?[] {100m, 98m, true},
@ -14,14 +14,14 @@ public class QualityItemTest
new object?[] {QualityItem.MaxUnlimitedThreshold, null, false}, new object?[] {QualityItem.MaxUnlimitedThreshold, null, false},
new object?[] {QualityItem.MaxUnlimitedThreshold - 1, null, true}, new object?[] {QualityItem.MaxUnlimitedThreshold - 1, null, true},
new object?[] {QualityItem.MaxUnlimitedThreshold, QualityItem.MaxUnlimitedThreshold, true} new object?[] {QualityItem.MaxUnlimitedThreshold, QualityItem.MaxUnlimitedThreshold, true}
}; ];
private static readonly object[] MinTestValues = private static readonly object[] MinTestValues =
{ [
new object?[] {0m, 0m, false}, new object?[] {0m, 0m, false},
new object?[] {0m, -1m, true}, new object?[] {0m, -1m, true},
new object?[] {0m, 1m, true} new object?[] {0m, 1m, true}
}; ];
[TestCaseSource(nameof(MaxTestValues))] [TestCaseSource(nameof(MaxTestValues))]
public void MaxDifferent_WithVariousValues_ReturnsExpectedResult( public void MaxDifferent_WithVariousValues_ReturnsExpectedResult(

@ -6,7 +6,7 @@ namespace Recyclarr.Tests.TrashGuide.QualitySize;
public class QualitySizeItemTest public class QualitySizeItemTest
{ {
private static readonly object[] PreferredTestValues = private static readonly object[] PreferredTestValues =
{ [
new object?[] {100m, 100m, false}, new object?[] {100m, 100m, false},
new object?[] {100m, 101m, true}, new object?[] {100m, 101m, true},
new object?[] {100m, 98m, true}, new object?[] {100m, 98m, true},
@ -15,7 +15,7 @@ public class QualitySizeItemTest
new object?[] {QualitySizeItem.PreferredUnlimitedThreshold - 1, null, true}, new object?[] {QualitySizeItem.PreferredUnlimitedThreshold - 1, null, true},
new object?[] new object?[]
{QualitySizeItem.PreferredUnlimitedThreshold, QualitySizeItem.PreferredUnlimitedThreshold, true} {QualitySizeItem.PreferredUnlimitedThreshold, QualitySizeItem.PreferredUnlimitedThreshold, true}
}; ];
[TestCaseSource(nameof(PreferredTestValues))] [TestCaseSource(nameof(PreferredTestValues))]
public void PreferredDifferent_WithVariousValues_ReturnsExpectedResult( public void PreferredDifferent_WithVariousValues_ReturnsExpectedResult(
@ -29,7 +29,7 @@ public class QualitySizeItemTest
} }
private static readonly object[] InterpolatedPreferredTestParams = private static readonly object[] InterpolatedPreferredTestParams =
{ [
new[] new[]
{ {
400m, 400m,
@ -60,7 +60,7 @@ public class QualitySizeItemTest
0.5m, 0.5m,
50m 50m
} }
}; ];
[TestCaseSource(nameof(InterpolatedPreferredTestParams))] [TestCaseSource(nameof(InterpolatedPreferredTestParams))]
public void InterpolatedPreferred_VariousValues_ExpectedResults( public void InterpolatedPreferred_VariousValues_ExpectedResults(

Loading…
Cancel
Save