Skip to content

Commit

Permalink
Updating nuget rules (#653)
Browse files Browse the repository at this point in the history
* Updated new rules

* updated logic

* Updated total count logic

* code gardening

* updated logic for nuget updates
  • Loading branch information
samsmithnz authored Nov 13, 2023
1 parent b1b1ec6 commit 17bca0f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/RepoGovernance.Core/Models/SummaryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public int TotalRecommendationCount
DependabotRecommendations.Count +
BranchPoliciesRecommendations.Count +
GitVersionRecommendations.Count +
DotNetFrameworksRecommendations.Count;
DotNetFrameworksRecommendations.Count +
NuGetPackages.Count;
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/RepoGovernance.Core/SummaryItemsDA.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DotNetCensus.Core.Models;
using GitHubActionsDotNet.Models.Dependabot;
using GitHubActionsDotNet.Serialization;
using RepoAutomation.Core.APIAccess;
using RepoAutomation.Core.Helpers;
Expand Down Expand Up @@ -98,6 +97,11 @@ public static async Task<int> UpdateSummaryItem(string? clientId,
{
azureDeployment = existingItem.AzureDeployment;
}
//save the nuget packages - since they are updated in a separate process, and we don't want to lose them here.
if (existingItem != null && existingItem.NuGetPackages.Count > 0)
{
summaryItem.NuGetPackages = existingItem.NuGetPackages;
}
}

try
Expand Down
6 changes: 3 additions & 3 deletions src/RepoGovernance.Tests/SummaryItemsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ public async Task GetSummaryItemsTest()
Assert.AreEqual("Consider disabling 'Allow rebase merge' in repo settings, as rebasing can be confusing", item6.RepoSettingsRecommendations[2]);
}
Assert.IsNotNull(item6.NuGetPackages);
Assert.AreEqual(item6.NuGetPackages.Count(x => x.Type == "Deprecated"), 0);
Assert.AreEqual(item6.NuGetPackages.Count(x => x.Type == "Outdated"), 4);
Assert.AreEqual(item6.NuGetPackages.Count(x => x.Type == "Vulnerable"), 0);
Assert.AreEqual(2, item6.NuGetPackages.Count(x => x.Type == "Deprecated"));
Assert.AreEqual(5, item6.NuGetPackages.Count(x => x.Type == "Outdated"));
Assert.AreEqual(1, item6.NuGetPackages.Count(x => x.Type == "Vulnerable"));
}


Expand Down
11 changes: 8 additions & 3 deletions src/RepoGovernance.Web/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@
<div>
@if (item.TotalRecommendationCount >= 0)
{
@if (item.RepoSettingsRecommendations.Count == 0 &&
@if (item != null && item.RepoSettingsRecommendations.Count == 0 &&
item.BranchPolicies != null && item.BranchPoliciesRecommendations.Count == 0 &&
item.Actions.Count > 0 && item.ActionRecommendations.Count == 0 &&
item.Dependabot.Count > 0 && item.DependabotRecommendations.Count == 0 &&
item.GitVersion.Count > 0 && item.GitVersionRecommendations.Count == 0)
item.GitVersion.Count > 0 && item.GitVersionRecommendations.Count == 0 &&
item.NuGetPackages != null && item.NuGetPackages.Count == 0)
{
<i class="bi bi-heart-fill greenHeart" data-toggle="tooltip" data-placement="bottom" title="OK"></i> <span>0</span>
}
Expand All @@ -111,6 +112,10 @@
{
recommendation += " - " + itemRec + Environment.NewLine + Environment.NewLine;
}
if (item != null && item.NuGetPackages != null && item.NuGetPackages.Count > 0)
{
recommendation += " - " + item.NuGetPackages.Count.ToString() + " NuGet packages require upgrades" + Environment.NewLine + Environment.NewLine;
}
<i class="bi bi-heart-pulse redHeart" data-toggle="tooltip" data-placement="bottom" title="@recommendation"></i> <span style="font-size: 14px;">@item.TotalRecommendationCount</span>
}
}
Expand Down Expand Up @@ -242,7 +247,7 @@
}
@if (item.NuGetPackages != null && item.NuGetPackages.Count > 0)
{
<strong style="font-size:14px;">NuGet packages :</strong>
<strong style="font-size:14px;">NuGet updates required:</strong>
<br />
<div style="font-size:12px;">
<ul>
Expand Down

0 comments on commit 17bca0f

Please sign in to comment.