From 8d7f7ee6a4e7fc7234c317b446d3afc70f13d942 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Thu, 9 Jan 2025 18:02:44 +0100 Subject: [PATCH] formatted the code --- .../Provider/GitHubProviderTests.cs | 2 +- .../VcsServiceTests.cs | 3 +- .../Exceptions/InvalidIssuesException.cs | 2 +- .../MappingProfiles/GitLabProfile.cs | 2 +- .../Model/VcsProvider.cs | 2 +- .../Options/BaseSubOptions.cs | 3 +- .../Provider/GitHubProvider.cs | 52 +++++++++---------- .../Provider/GitLabProvider.cs | 6 +-- .../ReleaseNotes/ReleaseNotesBuilder.cs | 4 +- .../GitLabProviderIntegrationTests.cs | 2 +- 10 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/GitReleaseManager.Core.Tests/Provider/GitHubProviderTests.cs b/src/GitReleaseManager.Core.Tests/Provider/GitHubProviderTests.cs index a9e1c563..a70d9c58 100644 --- a/src/GitReleaseManager.Core.Tests/Provider/GitHubProviderTests.cs +++ b/src/GitReleaseManager.Core.Tests/Provider/GitHubProviderTests.cs @@ -20,7 +20,7 @@ using NotFoundException = GitReleaseManager.Core.Exceptions.NotFoundException; using RateLimit = GitReleaseManager.Core.Model.RateLimit; using Release = GitReleaseManager.Core.Model.Release; -using ReleaseAsset= GitReleaseManager.Core.Model.ReleaseAsset; +using ReleaseAsset = GitReleaseManager.Core.Model.ReleaseAsset; using ReleaseAssetUpload = GitReleaseManager.Core.Model.ReleaseAssetUpload; namespace GitReleaseManager.Core.Tests.Provider diff --git a/src/GitReleaseManager.Core.Tests/VcsServiceTests.cs b/src/GitReleaseManager.Core.Tests/VcsServiceTests.cs index 86306af7..03de7a4d 100644 --- a/src/GitReleaseManager.Core.Tests/VcsServiceTests.cs +++ b/src/GitReleaseManager.Core.Tests/VcsServiceTests.cs @@ -350,8 +350,7 @@ public async Task Should_Create_Release_From_Milestone_With_Assets() null, _assets, false, - null - ).ConfigureAwait(false); + null).ConfigureAwait(false); result.ShouldBeSameAs(release); await _releaseNotesBuilder.Received(1).BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false); diff --git a/src/GitReleaseManager.Core/Exceptions/InvalidIssuesException.cs b/src/GitReleaseManager.Core/Exceptions/InvalidIssuesException.cs index bad42797..c9ecda2d 100644 --- a/src/GitReleaseManager.Core/Exceptions/InvalidIssuesException.cs +++ b/src/GitReleaseManager.Core/Exceptions/InvalidIssuesException.cs @@ -37,4 +37,4 @@ protected InvalidIssuesException( { } } -} +} \ No newline at end of file diff --git a/src/GitReleaseManager.Core/MappingProfiles/GitLabProfile.cs b/src/GitReleaseManager.Core/MappingProfiles/GitLabProfile.cs index c209654d..e8d3aad4 100644 --- a/src/GitReleaseManager.Core/MappingProfiles/GitLabProfile.cs +++ b/src/GitReleaseManager.Core/MappingProfiles/GitLabProfile.cs @@ -45,4 +45,4 @@ public GitLabProfile() .ReverseMap(); } } -} +} \ No newline at end of file diff --git a/src/GitReleaseManager.Core/Model/VcsProvider.cs b/src/GitReleaseManager.Core/Model/VcsProvider.cs index 565b218e..71f9330a 100644 --- a/src/GitReleaseManager.Core/Model/VcsProvider.cs +++ b/src/GitReleaseManager.Core/Model/VcsProvider.cs @@ -5,4 +5,4 @@ public enum VcsProvider GitHub = 0, GitLab = 1, } -} +} \ No newline at end of file diff --git a/src/GitReleaseManager.Core/Options/BaseSubOptions.cs b/src/GitReleaseManager.Core/Options/BaseSubOptions.cs index 9d8b1251..39593e1b 100644 --- a/src/GitReleaseManager.Core/Options/BaseSubOptions.cs +++ b/src/GitReleaseManager.Core/Options/BaseSubOptions.cs @@ -9,8 +9,7 @@ protected BaseSubOptions() { var ciEnvironmentVariable = Environment.GetEnvironmentVariable("CI"); - bool isCiSystem; - if (!string.IsNullOrEmpty(ciEnvironmentVariable) && bool.TryParse(ciEnvironmentVariable, out isCiSystem)) + if (!string.IsNullOrEmpty(ciEnvironmentVariable) && bool.TryParse(ciEnvironmentVariable, out bool isCiSystem)) { IsCISystem = isCiSystem; } diff --git a/src/GitReleaseManager.Core/Provider/GitHubProvider.cs b/src/GitReleaseManager.Core/Provider/GitHubProvider.cs index 68d19c4a..462e241b 100644 --- a/src/GitReleaseManager.Core/Provider/GitHubProvider.cs +++ b/src/GitReleaseManager.Core/Provider/GitHubProvider.cs @@ -37,7 +37,7 @@ public GitHubProvider(IGitHubClient gitHubClient, IMapper mapper) public Task DeleteAssetAsync(string owner, string repository, ReleaseAsset asset) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { await _gitHubClient.Repository.Release.DeleteAsset(owner, repository, asset.Id).ConfigureAwait(false); }); @@ -45,7 +45,7 @@ public Task DeleteAssetAsync(string owner, string repository, ReleaseAsset asset public Task UploadAssetAsync(Release release, ReleaseAssetUpload releaseAssetUpload) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var octokitRelease = _mapper.Map(release); var octokitReleaseAssetUpload = _mapper.Map(releaseAssetUpload); @@ -56,7 +56,7 @@ public Task UploadAssetAsync(Release release, ReleaseAssetUpload releaseAssetUpl public Task GetCommitsCountAsync(string owner, string repository, string @base, string head) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { try { @@ -87,7 +87,7 @@ public string GetCommitsUrl(string owner, string repository, string head, string public Task CreateIssueCommentAsync(string owner, string repository, Issue issue, string comment) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { await _gitHubClient.Issue.Comment.Create(owner, repository, issue.PublicNumber, comment).ConfigureAwait(false); }); @@ -95,7 +95,7 @@ public Task CreateIssueCommentAsync(string owner, string repository, Issue issue public Task> GetIssuesAsync(string owner, string repository, Milestone milestone, ItemStateFilter itemStateFilter = ItemStateFilter.All) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var openIssueRequest = new RepositoryIssueRequest { @@ -109,7 +109,7 @@ public Task> GetIssuesAsync(string owner, string repository, do { - var options = GetApiOptions(startPage); + var options = GitHubProvider.GetApiOptions(startPage); results = await _gitHubClient.Issue.GetAllForRepository(owner, repository, openIssueRequest, options).ConfigureAwait(false); issues.AddRange(results); @@ -123,7 +123,7 @@ public Task> GetIssuesAsync(string owner, string repository, public Task> GetIssueCommentsAsync(string owner, string repository, Issue issue) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var startPage = 1; var comments = new List(); @@ -131,7 +131,7 @@ public Task> GetIssueCommentsAsync(string owner, strin do { - var options = GetApiOptions(startPage); + var options = GitHubProvider.GetApiOptions(startPage); results = await _gitHubClient.Issue.Comment.GetAllForIssue(owner, repository, issue.PublicNumber, options).ConfigureAwait(false); comments.AddRange(results); @@ -145,7 +145,7 @@ public Task> GetIssueCommentsAsync(string owner, strin public Task CreateLabelAsync(string owner, string repository, Label label) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var newLabel = _mapper.Map(label); @@ -155,7 +155,7 @@ public Task CreateLabelAsync(string owner, string repository, Label label) public Task DeleteLabelAsync(string owner, string repository, Label label) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { await _gitHubClient.Issue.Labels.Delete(owner, repository, label.Name).ConfigureAwait(false); }); @@ -163,7 +163,7 @@ public Task DeleteLabelAsync(string owner, string repository, Label label) public Task> GetLabelsAsync(string owner, string repository) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var startPage = 1; var labels = new List(); @@ -171,7 +171,7 @@ public Task> GetLabelsAsync(string owner, string repository) do { - var options = GetApiOptions(startPage); + var options = GitHubProvider.GetApiOptions(startPage); results = await _gitHubClient.Issue.Labels.GetAllForRepository(owner, repository, options).ConfigureAwait(false); labels.AddRange(results); @@ -185,7 +185,7 @@ public Task> GetLabelsAsync(string owner, string repository) public Task GetMilestoneAsync(string owner, string repository, string milestoneTitle, ItemStateFilter itemStateFilter = ItemStateFilter.All) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var milestones = await GetMilestonesAsync(owner, repository, itemStateFilter).ConfigureAwait(false); var foundMilestone = milestones.FirstOrDefault(m => m.Title == milestoneTitle); @@ -201,7 +201,7 @@ public Task GetMilestoneAsync(string owner, string repository, string public Task> GetMilestonesAsync(string owner, string repository, ItemStateFilter itemStateFilter = ItemStateFilter.All) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var request = new MilestoneRequest { State = (Octokit.ItemStateFilter)itemStateFilter }; @@ -211,7 +211,7 @@ public Task> GetMilestonesAsync(string owner, string repo do { - var options = GetApiOptions(startPage); + var options = GitHubProvider.GetApiOptions(startPage); results = await _gitHubClient.Issue.Milestone.GetAllForRepository(owner, repository, request, options).ConfigureAwait(false); milestones.AddRange(results); @@ -225,7 +225,7 @@ public Task> GetMilestonesAsync(string owner, string repo public Task SetMilestoneStateAsync(string owner, string repository, Milestone milestone, ItemState itemState) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var update = new MilestoneUpdate { State = (Octokit.ItemState)itemState }; await _gitHubClient.Issue.Milestone.Update(owner, repository, milestone.PublicNumber, update).ConfigureAwait(false); @@ -234,7 +234,7 @@ public Task SetMilestoneStateAsync(string owner, string repository, Milestone mi public Task CreateReleaseAsync(string owner, string repository, Release release) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var newRelease = _mapper.Map(release); var octokitRelease = await _gitHubClient.Repository.Release.Create(owner, repository, newRelease).ConfigureAwait(false); @@ -245,7 +245,7 @@ public Task CreateReleaseAsync(string owner, string repository, Release public Task DeleteReleaseAsync(string owner, string repository, Release release) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { await _gitHubClient.Repository.Release.Delete(owner, repository, release.Id).ConfigureAwait(false); }); @@ -253,7 +253,7 @@ public Task DeleteReleaseAsync(string owner, string repository, Release release) public Task GetReleaseAsync(string owner, string repository, string tagName) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { // This method wants to return a single Release, that has the tagName that is requested. // The obvious thing to do here would be to use Repository.Release.Get, however, this doesn't @@ -270,7 +270,7 @@ public Task GetReleaseAsync(string owner, string repository, string tag public Task> GetReleasesAsync(string owner, string repository, bool skipPrereleases) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var startPage = 1; var releases = new List(); @@ -278,7 +278,7 @@ public Task> GetReleasesAsync(string owner, string reposito do { - var options = GetApiOptions(startPage); + var options = GitHubProvider.GetApiOptions(startPage); results = await _gitHubClient.Repository.Release.GetAll(owner, repository, options).ConfigureAwait(false); if (skipPrereleases) @@ -302,7 +302,7 @@ public Task> GetReleasesAsync(string owner, string reposito public Task PublishReleaseAsync(string owner, string repository, string tagName, Release release) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var update = new ReleaseUpdate { @@ -316,7 +316,7 @@ public Task PublishReleaseAsync(string owner, string repository, string tagName, public Task UpdateReleaseAsync(string owner, string repository, Release release) { - return ExecuteAsync(async () => + return GitHubProvider.ExecuteAsync(async () => { var update = new ReleaseUpdate { @@ -356,7 +356,7 @@ public string GetIssueType(Issue issue) return issue.IsPullRequest ? "Pull Request" : "Issue"; } - private async Task ExecuteAsync(Func action) + private static async Task ExecuteAsync(Func action) { try { @@ -376,7 +376,7 @@ private async Task ExecuteAsync(Func action) } } - private async Task ExecuteAsync(Func> action) + private static async Task ExecuteAsync(Func> action) { try { @@ -396,7 +396,7 @@ private async Task ExecuteAsync(Func> action) } } - private ApiOptions GetApiOptions(int startPage = 1, int pageSize = 100, int pageCount = 1) + private static ApiOptions GetApiOptions(int startPage = 1, int pageSize = 100, int pageCount = 1) { return new ApiOptions { diff --git a/src/GitReleaseManager.Core/Provider/GitLabProvider.cs b/src/GitReleaseManager.Core/Provider/GitLabProvider.cs index d84b6e3a..1d4a3138 100644 --- a/src/GitReleaseManager.Core/Provider/GitLabProvider.cs +++ b/src/GitReleaseManager.Core/Provider/GitLabProvider.cs @@ -405,7 +405,7 @@ private long GetGitLabProjectId(string owner, string repository) return _projectId.Value; } - private async Task ExecuteAsync(Func action) + private static async Task ExecuteAsync(Func action) { try { @@ -421,7 +421,7 @@ private async Task ExecuteAsync(Func action) } } - private async Task ExecuteAsync(Func> action) + private static async Task ExecuteAsync(Func> action) { try { @@ -437,4 +437,4 @@ private async Task ExecuteAsync(Func> action) } } } -} +} \ No newline at end of file diff --git a/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs b/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs index ff4584eb..ec08fec0 100644 --- a/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs +++ b/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs @@ -143,9 +143,9 @@ private string GetValidLabel(string label, int issuesCount) foreach (var issueLabel in issue.Labels) { - includedIssuesCount += _configuration.IssueLabelsInclude.Count(issueToInclude => issueLabel.Name.ToUpperInvariant() == issueToInclude.ToUpperInvariant()); + includedIssuesCount += _configuration.IssueLabelsInclude.Count(issueToInclude => string.Equals(issueLabel.Name, issueToInclude, StringComparison.InvariantCultureIgnoreCase)); - isExcluded = isExcluded || _configuration.IssueLabelsExclude.Any(issueToExclude => issueLabel.Name.ToUpperInvariant() == issueToExclude.ToUpperInvariant()); + isExcluded = isExcluded || _configuration.IssueLabelsExclude.Any(issueToExclude => string.Equals(issueLabel.Name, issueToExclude, StringComparison.InvariantCultureIgnoreCase)); } if (isExcluded) diff --git a/src/GitReleaseManager.IntegrationTests/GitLabProviderIntegrationTests.cs b/src/GitReleaseManager.IntegrationTests/GitLabProviderIntegrationTests.cs index 169f9e91..e7137783 100644 --- a/src/GitReleaseManager.IntegrationTests/GitLabProviderIntegrationTests.cs +++ b/src/GitReleaseManager.IntegrationTests/GitLabProviderIntegrationTests.cs @@ -108,4 +108,4 @@ public async Task Should_Get_Commits_Count() // result.ShouldBeGreaterThan(0); } } -} +} \ No newline at end of file