refactor: Use collection expressions in a few places

pull/231/head
Robert Dailey 1 month ago
parent 9bd66d0e1e
commit 75a87707bf

@ -2,7 +2,7 @@ namespace Recyclarr.Cli.Pipelines.MediaNaming.PipelinePhases.Config;
public class NamingFormatLookup
{
private readonly List<InvalidNamingConfig> _errors = new();
private readonly List<InvalidNamingConfig> _errors = [];
public IReadOnlyCollection<InvalidNamingConfig> Errors => _errors;
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.
private static readonly string[] ValidGitPaths =
{
[
".git/config",
".git/index",
".git/HEAD"
};
];
public async Task<IGitRepository> CreateAndCloneIfNeeded(
Uri repoUrl,

@ -7,7 +7,7 @@ namespace Recyclarr.Yaml.YamlDotNet;
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)
{

@ -35,7 +35,7 @@ public class CompositionRootTest
.Select(x => x.ServiceType)
.Distinct()
.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();
}
}

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

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

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

Loading…
Cancel
Save