From 3060eb066304e3b9a101d4df8fbfd6daee4914c3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2020 14:15:34 +0000 Subject: [PATCH 1/6] Bump xunit.runner.visualstudio from 2.4.2 to 2.4.3 in /src Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.4.2 to 2.4.3. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/v2.4.2...v2.4.3) Signed-off-by: dependabot-preview[bot] --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 3e2096f..7a6dbff 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -18,7 +18,7 @@ - + From 697a66381f4ca3294911540b7ba30ade05a21907 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 6 Aug 2020 12:23:35 +0000 Subject: [PATCH 2/6] Bump Microsoft.NET.Test.Sdk from 16.6.1 to 16.7.0 in /src Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.6.1 to 16.7.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.6.1...v16.7.0) Signed-off-by: dependabot-preview[bot] --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 7a6dbff..1de714c 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.PullRequests.Tests.ruleset - + From c5b142ead3bd089e74efb286d0a7ea08096972ab Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 22 Aug 2020 19:16:01 +0000 Subject: [PATCH 3/6] Bump Microsoft.NET.Test.Sdk from 16.7.0 to 16.7.1 in /src Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.7.0 to 16.7.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.7.0...v16.7.1) Signed-off-by: dependabot-preview[bot] --- .../Cake.Issues.PullRequests.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj index 79ded12..47c8e5f 100644 --- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj +++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj @@ -10,7 +10,7 @@ ..\Cake.Issues.PullRequests.Tests.ruleset - + From fcd45ab3cc1a7a934a854771ccefaf353cbbb82b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 22 Aug 2020 20:51:20 +0000 Subject: [PATCH 4/6] Bump Microsoft.CodeAnalysis.FxCopAnalyzers from 3.0.0 to 3.3.0 in /src Bumps [Microsoft.CodeAnalysis.FxCopAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 3.0.0 to 3.3.0. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/master/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/v3.0.0...v3.3.0) Signed-off-by: dependabot-preview[bot] --- src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj index 0170e3e..30046ec 100644 --- a/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj +++ b/src/Cake.Issues.PullRequests/Cake.Issues.PullRequests.csproj @@ -27,7 +27,7 @@ - + From 5b4e9ffbb959bd6dc9f47036cb1a06d8c2462cd8 Mon Sep 17 00:00:00 2001 From: janniksam Date: Sat, 26 Sep 2020 04:02:21 +0200 Subject: [PATCH 5/6] FIxed negative / zero limits. --- .../IssueFiltererTests.cs | 261 ++++++++++++++++++ src/Cake.Issues.PullRequests/IssueFilterer.cs | 21 +- 2 files changed, 275 insertions(+), 7 deletions(-) diff --git a/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs b/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs index ad8d41f..ec75b66 100644 --- a/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs +++ b/src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs @@ -547,6 +547,152 @@ public void Should_Limit_Messages_To_Maximum() fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 2 across all runs for provider 'ProviderType Foo' (2 issues already posted in previous runs)"); } + [Fact] + public void Should_Limit_Messages_To_Zero() + { + // Given + var fixture = new IssueFiltererFixture(); + fixture.Settings.ProviderIssueLimits.Add( + "ProviderType Foo", + new ProviderIssueIssueLimits(maxIssuesToPostAcrossRuns: 0)); + + var newIssue1 = + IssueBuilder + .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 10) + .OfRule("Rule Foo") + .WithPriority(IssuePriority.Warning) + .Create(); + + var newIssue2 = + IssueBuilder + .NewIssue("Message Bar", "ProviderType Bar", "ProviderName Bar") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + + // When + var issues = + fixture.FilterIssues( + new List + { + newIssue1, newIssue2 + }, + new Dictionary(), + new List + { + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false + } + }) + { + ProviderType = "ProviderType Foo" + }, + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false + } + }) + { + ProviderType = "ProviderType Foo" + } + }); + + // Then + issues.Count().ShouldBe(1); + issues.ShouldContain(newIssue2); + fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global issue limit of 0 across all runs for provider 'ProviderType Foo' (2 issues already posted in previous runs)"); + } + + [Fact] + public void Should_Ignore_Limit_When_Negative() + { + // Given + var fixture = new IssueFiltererFixture(); + fixture.Settings.ProviderIssueLimits.Add( + "ProviderType Foo", + new ProviderIssueIssueLimits(maxIssuesToPostAcrossRuns: -3)); + + var newIssue1 = + IssueBuilder + .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 10) + .OfRule("Rule Foo") + .WithPriority(IssuePriority.Warning) + .Create(); + + var newIssue2 = + IssueBuilder + .NewIssue("Message Bar", "ProviderType Foo", "ProviderName Foo") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + + // When + var issues = + fixture.FilterIssues( + new List + { + newIssue1, newIssue2 + }, + new Dictionary(), + new List + { + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false + } + }) + { + ProviderType = "ProviderType Foo" + }, + new PullRequestDiscussionThread( + 1, + PullRequestDiscussionStatus.Active, + @"src\Cake.Issues.Tests\FakeIssueProvider.cs", + new List + { + new PullRequestDiscussionComment + { + Content = "Message FooBar", + IsDeleted = false + } + }) + { + ProviderType = "ProviderType Foo" + } + }); + + // Then + issues.Count().ShouldBe(2); + issues.ShouldContain(newIssue1); + issues.ShouldContain(newIssue2); + } + [Fact] public void Should_Limit_Messages_To_Maximum_By_Priority() { @@ -749,6 +895,121 @@ public void Should_Limit_Messages_To_Maximum() fixture.Log.Entries.ShouldContain(x => x.Message == "1 issue(s) were filtered to match the global limit of 1 issues which should be reported for issue provider 'ProviderTypeB'"); } + [Fact] + public void Should_Limit_Messages_To_Zero() + { + // Given + var fixture = new IssueFiltererFixture(); + fixture.Settings.ProviderIssueLimits.Add( + "ProviderTypeA", + new ProviderIssueIssueLimits(maxIssuesToPost: 0)); + fixture.Settings.ProviderIssueLimits.Add( + "ProviderTypeB", + new ProviderIssueIssueLimits(maxIssuesToPost: 0)); + + var issue1 = + IssueBuilder + .NewIssue("Message Foo", "ProviderTypeA", "ProviderNameA") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 10) + .OfRule("Rule Foo") + .WithPriority(IssuePriority.Warning) + .Create(); + var issue2 = + IssueBuilder + .NewIssue("Message Bar", "ProviderTypeA", "ProviderNameA") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + var issue3 = + IssueBuilder + .NewIssue("Message Foo", "ProviderTypeB", "ProviderNameB") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 10) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + var issue4 = + IssueBuilder + .NewIssue("Message Bar", "ProviderTypeB", "ProviderNameB") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + + // When + var issues = + fixture.FilterIssues( + new List + { + issue1, issue2, issue3, issue4 + }, + new Dictionary()); + + // Then + issues.Count().ShouldBe(0); + + fixture.Log.Entries.ShouldContain(x => x.Message == "2 issue(s) were filtered to match the global limit of 0 issues which should be reported for issue provider 'ProviderTypeA'"); + fixture.Log.Entries.ShouldContain(x => x.Message == "2 issue(s) were filtered to match the global limit of 0 issues which should be reported for issue provider 'ProviderTypeB'"); + } + + [Fact] + public void Should_Ignore_Limit_When_Negative() + { + // Given + var fixture = new IssueFiltererFixture(); + fixture.Settings.ProviderIssueLimits.Add( + "ProviderTypeA", + new ProviderIssueIssueLimits(maxIssuesToPost: -3)); + fixture.Settings.ProviderIssueLimits.Add( + "ProviderTypeB", + new ProviderIssueIssueLimits(maxIssuesToPost: -1)); + + var issue1 = + IssueBuilder + .NewIssue("Message Foo", "ProviderTypeA", "ProviderNameA") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 10) + .OfRule("Rule Foo") + .WithPriority(IssuePriority.Warning) + .Create(); + var issue2 = + IssueBuilder + .NewIssue("Message Bar", "ProviderTypeA", "ProviderNameA") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + var issue3 = + IssueBuilder + .NewIssue("Message Foo", "ProviderTypeB", "ProviderNameB") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 10) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + var issue4 = + IssueBuilder + .NewIssue("Message Bar", "ProviderTypeB", "ProviderNameB") + .InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) + .OfRule("Rule Bar") + .WithPriority(IssuePriority.Warning) + .Create(); + + // When + var issues = + fixture.FilterIssues( + new List + { + issue1, issue2, issue3, issue4 + }, + new Dictionary()); + + // Then + issues.Count().ShouldBe(4); + issues.ShouldContain(issue1); + issues.ShouldContain(issue2); + issues.ShouldContain(issue3); + issues.ShouldContain(issue4); + } + [Fact] public void Should_Limit_Messages_To_Maximum_By_Priority() { diff --git a/src/Cake.Issues.PullRequests/IssueFilterer.cs b/src/Cake.Issues.PullRequests/IssueFilterer.cs index 5a65e6f..c537c50 100644 --- a/src/Cake.Issues.PullRequests/IssueFilterer.cs +++ b/src/Cake.Issues.PullRequests/IssueFilterer.cs @@ -252,8 +252,9 @@ private IList FilterIssuesByPath(IList issues) // Apply issue limits per provider for this run foreach (var currentProviderLimitPair in this.settings.ProviderIssueLimits) { - var currentProviderTypeMaxLimit = (currentProviderLimitPair.Value?.MaxIssuesToPost).GetValueOrDefault(); - if (currentProviderTypeMaxLimit <= 0) + var currentProviderTypeMaxLimit = currentProviderLimitPair.Value?.MaxIssuesToPost; + if (!currentProviderTypeMaxLimit.HasValue || + currentProviderTypeMaxLimit < 0) { continue; } @@ -271,7 +272,7 @@ private IList FilterIssuesByPath(IList issues) var countBefore = result.Count; result = result.Where(p => p.ProviderType != currentProviderType) - .Concat(newIssuesForProviderType.Take(currentProviderTypeMaxLimit)) + .Concat(newIssuesForProviderType.Take(currentProviderTypeMaxLimit.Value)) .ToList(); var issuesFilteredCount = countBefore - result.Count; @@ -303,18 +304,24 @@ private IList FilterIssuesByPath(IList issues) // Apply issue limits per provider across mulitple runs foreach (var currentProviderLimitPair in this.settings.ProviderIssueLimits) { - var currentProviderTypeMaxLimit = (currentProviderLimitPair.Value?.MaxIssuesToPostAcrossRuns).GetValueOrDefault(); - if (currentProviderTypeMaxLimit <= 0) + var currentProviderTypeMaxLimit = currentProviderLimitPair.Value?.MaxIssuesToPostAcrossRuns; + if (!currentProviderTypeMaxLimit.HasValue || + currentProviderTypeMaxLimit < 0) { continue; } var currentProviderType = currentProviderLimitPair.Key; - var existingThreadCountForProvider = existingThreads.Count(p => p.ProviderType == currentProviderType); + var maxIssuesLeftToTakeForProviderType = - currentProviderTypeMaxLimit - existingThreadCountForProvider; + currentProviderTypeMaxLimit.Value - existingThreadCountForProvider; + if (maxIssuesLeftToTakeForProviderType < 0) + { + maxIssuesLeftToTakeForProviderType = 0; + } + var newIssuesForProviderType = result.Where(p => p.ProviderType == currentProviderType) .SortWithDefaultPriorization() From 135e5990d5cd15b905e8b833988a67ccec9ca095 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Fri, 9 Oct 2020 01:27:21 +0200 Subject: [PATCH 6/6] Update release notes link --- nuspec/nuget/Cake.Issues.PullRequests.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuspec/nuget/Cake.Issues.PullRequests.nuspec b/nuspec/nuget/Cake.Issues.PullRequests.nuspec index b2612a4..22dff1a 100644 --- a/nuspec/nuget/Cake.Issues.PullRequests.nuspec +++ b/nuspec/nuget/Cake.Issues.PullRequests.nuspec @@ -22,7 +22,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin Copyright © BBT Software AG and contributors Cake Script Cake-Issues CodeAnalysis Linting Issues Pull-Requests - https://github.com/cake-contrib/Cake.Issues.PullRequests/releases/tag/0.9.0 + https://github.com/cake-contrib/Cake.Issues.PullRequests/releases/tag/0.9.1