Skip to content

Commit f272f1e

Browse files
authored
Fix linting issues (#461)
1 parent 910a2f3 commit f272f1e

File tree

8 files changed

+115
-112
lines changed

8 files changed

+115
-112
lines changed

src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetGitClientFactory.cs

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@ public override GitHttpClient CreateGitClient(Uri collectionUrl, IAzureDevOpsCre
4141
null,
4242
default))
4343
.ReturnsAsync((string _, string repoId2, GitPullRequestSearchCriteria sc, int _, int _, int _, object _, CancellationToken _)
44-
=> new List<GitPullRequest>(new[]
45-
{
46-
new GitPullRequest
47-
{
48-
PullRequestId = 777,
49-
Status = PullRequestStatus.Active,
50-
Repository = new GitRepository
44+
=>
45+
[
46+
new GitPullRequest
5147
{
52-
Id = Guid.NewGuid(),
53-
Name = repoId2,
48+
PullRequestId = 777,
49+
Status = PullRequestStatus.Active,
50+
Repository = new GitRepository
51+
{
52+
Id = Guid.NewGuid(),
53+
Name = repoId2,
54+
},
55+
SourceRefName = sc.SourceRefName,
56+
TargetRefName = "master",
57+
CodeReviewId = 123,
58+
LastMergeSourceCommit = new GitCommitRef { CommitId = "4a92b977" },
59+
LastMergeTargetCommit = new GitCommitRef { CommitId = "78a3c113" },
5460
},
55-
SourceRefName = sc.SourceRefName,
56-
TargetRefName = "master",
57-
CodeReviewId = 123,
58-
LastMergeSourceCommit = new GitCommitRef { CommitId = "4a92b977" },
59-
LastMergeTargetCommit = new GitCommitRef { CommitId = "78a3c113" },
60-
},
61-
}));
61+
]);
6262

6363
mock = this.Setup(mock);
6464

@@ -159,18 +159,18 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
159159
{
160160
FilePath = "/some/path/to/file.cs",
161161
},
162-
Comments = new List<Comment>
163-
{
164-
new () { Content = "Hello", IsDeleted = false, CommentType = CommentType.CodeChange, Id = 1 },
165-
new () { Content = "Goodbye", IsDeleted = true, CommentType = CommentType.Text, Id = 2 },
166-
},
162+
Comments =
163+
[
164+
new () { Content = "Hello", IsDeleted = false, CommentType = CommentType.CodeChange, Id = 1 },
165+
new () { Content = "Goodbye", IsDeleted = true, CommentType = CommentType.Text, Id = 2 },
166+
],
167167
Status = CommentThreadStatus.Active,
168168
},
169169
new ()
170170
{
171171
Id = 22,
172172
ThreadContext = null,
173-
Comments = new List<Comment>(),
173+
Comments = [],
174174
Status = CommentThreadStatus.Fixed,
175175
},
176176
};
@@ -201,11 +201,11 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
201201
null,
202202
CancellationToken.None))
203203
.ReturnsAsync((Guid _, int _, bool? _, object _, CancellationToken _)
204-
=> new List<GitPullRequestIteration>
205-
{
206-
new () { Id = 42, CreatedDate = DateTime.Today.AddDays(-3) },
207-
new () { Id = 16, CreatedDate = DateTime.Today.AddDays(-1) },
208-
});
204+
=>
205+
[
206+
new () { Id = 42, CreatedDate = DateTime.Today.AddDays(-3) },
207+
new () { Id = 16, CreatedDate = DateTime.Today.AddDays(-1) },
208+
]);
209209

210210
m.Setup(arg => arg.GetPullRequestIterationsAsync(
211211
It.IsAny<Guid>(),
@@ -214,19 +214,20 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
214214
null,
215215
CancellationToken.None))
216216
.ReturnsAsync((Guid _, int _, bool? _, object _, CancellationToken _)
217-
=> new List<GitPullRequestIteration>
218-
{
219-
new () { Id = null },
220-
});
217+
=>
218+
[
219+
new () { Id = null },
220+
]);
221221

222222
// Setup GitPullRequestIterationChanges collection
223223
var changes = new GitPullRequestIterationChanges
224224
{
225-
ChangeEntries = new List<GitPullRequestChange>
226-
{
227-
new () { ChangeId = 100, ChangeTrackingId = 1, Item = new GitItem { Path = "/src/my/class1.cs" } },
228-
new () { ChangeId = 200, ChangeTrackingId = 2, Item = new GitItem { Path = string.Empty } },
229-
},
225+
ChangeEntries =
226+
[
227+
new () { ChangeId = 100, ChangeTrackingId = 1, Item = new GitItem { Path = "/src/my/class1.cs" } },
228+
new () { ChangeId = 200, ChangeTrackingId = 2, Item = new GitItem { Path = string.Empty } },
229+
230+
],
230231
};
231232

232233
m.Setup(arg => arg.GetPullRequestIterationChangesAsync(
@@ -254,7 +255,7 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
254255
null,
255256
null,
256257
CancellationToken.None))
257-
.ReturnsAsync(() => new List<GitRef>());
258+
.ReturnsAsync(() => []);
258259

259260
m.Setup(args => args.GetRepositoryAsync(It.IsAny<string>(), "MyRepoName", null, CancellationToken.None))
260261
.ReturnsAsync(() => new GitRepository() { DefaultBranch = "master" });
@@ -271,10 +272,10 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
271272
null,
272273
null,
273274
CancellationToken.None))
274-
.ReturnsAsync(() => new List<GitRef>()
275-
{
276-
new ("master"),
277-
});
275+
.ReturnsAsync(() =>
276+
[
277+
new ("master"),
278+
]);
278279

279280
m.Setup(
280281
arg =>

src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetTestManagementClientFactory.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ public override TestManagementHttpClient CreateTestManagementClient(Uri collecti
1515
var mock = new Mock<TestManagementHttpClient>(MockBehavior.Strict, collectionUrl, credentials.ToVssCredentials());
1616

1717
mock.Setup(arg => arg.GetTestResultDetailsForBuildAsync(It.IsAny<Guid>(), It.Is<int>(id => id == 1), null, null, null, null, null, null, null, default))
18-
.ReturnsAsync(() => new TestResultsDetails { ResultsForGroup = new List<TestResultsDetailsForGroup>() });
18+
.ReturnsAsync(() => new TestResultsDetails { ResultsForGroup = [] });
1919

2020
mock.Setup(arg => arg.GetTestResultDetailsForBuildAsync(It.IsAny<Guid>(), It.Is<int>(id => id > 1), null, null, null, null, null, null, null, default))
2121
.ReturnsAsync(() => new TestResultsDetails
2222
{
23-
ResultsForGroup = new List<TestResultsDetailsForGroup>()
24-
{
25-
new ()
26-
{
27-
Results = new List<TestCaseResult>()
23+
ResultsForGroup =
24+
[
25+
new ()
2826
{
29-
new () { Id = 11, TestRun = new ShallowReference { Id = "1" } },
30-
new () { Id = 12, TestRun = new ShallowReference { Id = "1" } },
31-
new () { Id = 13, TestRun = new ShallowReference { Id = "1" } },
27+
Results =
28+
[
29+
new () { Id = 11, TestRun = new ShallowReference { Id = "1" } },
30+
new () { Id = 12, TestRun = new ShallowReference { Id = "1" } },
31+
new () { Id = 13, TestRun = new ShallowReference { Id = "1" } },
32+
],
3233
},
33-
},
34-
},
34+
],
3535
});
3636

3737
mock.Setup(arg => arg.GetTestResultsAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, It.IsAny<int?>(), It.IsAny<int?>(), It.IsAny<IEnumerable<TestOutcome>>(), null, default))

src/Cake.AzureDevOps.Tests/Fakes/FakeNullForMethodsGitClientFactory.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
1717
.ReturnsAsync(() => null);
1818

1919
m.Setup(arg => arg.GetCommitDiffsAsync(It.IsAny<string>(), It.IsAny<Guid>(), true, null, null, It.IsAny<GitBaseVersionDescriptor>(), It.IsAny<GitTargetVersionDescriptor>(), null, CancellationToken.None))
20-
.ReturnsAsync(()
21-
=> new GitCommitDiffs { ChangeCounts = [], Changes = new List<GitChange>() });
20+
.ReturnsAsync(() => new GitCommitDiffs { ChangeCounts = [], Changes = [] });
2221

2322
m.Setup(arg => arg.UpdateThreadAsync(It.IsAny<GitPullRequestCommentThread>(), It.IsAny<Guid>(), It.IsAny<int>(), It.IsAny<int>(), null, CancellationToken.None))
2423
.ReturnsAsync(() => null);
2524

2625
m.Setup(arg => arg.GetThreadsAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, null, null, CancellationToken.None))
27-
.ReturnsAsync(() => new List<GitPullRequestCommentThread>());
26+
.ReturnsAsync(() => []);
2827

2928
m.Setup(arg => arg.CreateThreadAsync(It.IsAny<GitPullRequestCommentThread>(), It.IsAny<Guid>(), It.IsAny<int>(), null, CancellationToken.None))
3029
.ReturnsAsync(() => null);

src/Cake.AzureDevOps.Tests/Fakes/FakeNullGitClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public override GitHttpClient CreateGitClient(Uri collectionUrl, IAzureDevOpsCre
1616
.ReturnsAsync(() => null);
1717

1818
mock.Setup(arg => arg.GetPullRequestsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GitPullRequestSearchCriteria>(), null, null, 1, null, default))
19-
.ReturnsAsync(() => new List<GitPullRequest>());
19+
.ReturnsAsync(() => []);
2020

2121
mock = this.Setup(mock);
2222

src/Cake.AzureDevOps.Tests/Repos/PullRequest/CommentThread/AzureDevOpsPullRequestCommentThreadTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public void Should_Return_Valid_Comment_Thread()
5050
Id = 42,
5151
Status = CommentThreadStatus.Pending,
5252
ThreadContext = new CommentThreadContext { FilePath = "/src/myclass.cs" },
53-
Comments = new List<Comment> { new () { Content = "Hello", CommentType = CommentType.Text, IsDeleted = false } },
53+
Comments =
54+
[
55+
new () { Content = "Hello", CommentType = CommentType.Text, IsDeleted = false }
56+
],
5457
Properties = [],
5558
};
5659

@@ -152,7 +155,10 @@ public void Should_Set_Properly()
152155
// When
153156
var azureDevOpsThread = new AzureDevOpsPullRequestCommentThread(thread)
154157
{
155-
Comments = new List<AzureDevOpsComment> { new ("hi", false) },
158+
Comments =
159+
[
160+
new ("hi", false)
161+
],
156162
};
157163

158164
// Then

src/Cake.AzureDevOps/Authentication/AzureDevOpsBasicCredentials.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
/// <param name="password">Password.</param>
88
public class AzureDevOpsBasicCredentials(string userName, string password) : IAzureDevOpsCredentials
99
{
10-
1110
/// <summary>
1211
/// Gets the user name.
1312
/// </summary>

src/Cake.AzureDevOps/Pipelines/AzureDevOpsBuild.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public IEnumerable<AzureDevOpsChange> GetChanges()
358358
{
359359
if (!this.ValidateBuild())
360360
{
361-
return new List<AzureDevOpsChange>();
361+
return [];
362362
}
363363

364364
using (var buildClient = this.buildClientFactory.CreateBuildClient(this.CollectionUrl, this.settings.Credentials))
@@ -384,7 +384,7 @@ public IEnumerable<int> GetWorkItemIds()
384384
{
385385
if (!this.ValidateBuild())
386386
{
387-
return Array.Empty<int>();
387+
return [];
388388
}
389389

390390
using (var buildClient = this.buildClientFactory.CreateBuildClient(this.CollectionUrl, this.settings.Credentials))
@@ -403,7 +403,8 @@ public IEnumerable<int> GetWorkItemIds()
403403
throw new InvalidOperationException("Either ProjectId or ProjectName needs to be set");
404404
}
405405

406-
return task
406+
return
407+
task
407408
.ConfigureAwait(false)
408409
.GetAwaiter()
409410
.GetResult()
@@ -422,7 +423,7 @@ public IEnumerable<AzureDevOpsWorkItem> GetWorkItems()
422423
{
423424
if (!this.ValidateBuild())
424425
{
425-
return Array.Empty<AzureDevOpsWorkItem>();
426+
return [];
426427
}
427428

428429
var workItemIds = this.GetWorkItemIds();
@@ -463,7 +464,7 @@ public IEnumerable<AzureDevOpsTimelineRecord> GetTimelineRecords()
463464
{
464465
if (!this.ValidateBuild())
465466
{
466-
return new List<AzureDevOpsTimelineRecord>();
467+
return [];
467468
}
468469

469470
using (var buildClient = this.buildClientFactory.CreateBuildClient(this.CollectionUrl, this.settings.Credentials))
@@ -490,7 +491,7 @@ public IEnumerable<AzureDevOpsBuildArtifact> GetArtifacts()
490491
{
491492
if (!this.ValidateBuild())
492493
{
493-
return new List<AzureDevOpsBuildArtifact>();
494+
return [];
494495
}
495496

496497
using (var buildClient = this.buildClientFactory.CreateBuildClient(this.CollectionUrl, this.settings.Credentials))
@@ -610,7 +611,7 @@ public IEnumerable<AzureDevOpsTestRun> GetTestRuns(int? maxResultsPerTestRun, IE
610611
{
611612
if (!this.ValidateBuild())
612613
{
613-
return new List<AzureDevOpsTestRun>();
614+
return [];
614615
}
615616

616617
using (var testClient = this.testClientFactory.CreateTestManagementClient(this.CollectionUrl, this.settings.Credentials))

0 commit comments

Comments
 (0)