Skip to content

Commit

Permalink
VCI-772: Improve maintainability
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro committed Feb 22, 2024
1 parent a41421f commit b753f5f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/VirtoCommerce.Build/PlatformTools/Build.MatchVerisons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Nuke.Common;
using Nuke.Common.ProjectModel;
using Nuke.Common.Utilities;
using Nuke.Common.Utilities.Collections;
using PlatformTools;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Core.Modularity;
Expand Down Expand Up @@ -39,7 +40,7 @@ internal partial class Build
var missedDependenciesErrors = ValidateForMissedDependencies(allPackages);
errors.AddRange(missedDependenciesErrors);

if (errors.Count != 0)
if (!errors.IsEmpty())
{
Assert.Fail(errors.Join(Environment.NewLine));
}
Expand All @@ -48,7 +49,7 @@ internal partial class Build
/// <summary>
/// Get list of VirtoCommerce packages (platform and module)
/// </summary>
private IEnumerable<PackageItem> GetProjectPackages(Project project)
private static IEnumerable<PackageItem> GetProjectPackages(Project project)
{
var msBuildProject = project.GetMSBuildProject();

Expand Down Expand Up @@ -127,18 +128,18 @@ private List<string> ValidateForMissedDependencies(IEnumerable<PackageItem> pack
return result;
}

foreach (var packageGroup in packages.Where(x => !x.IsPlatformPackage).GroupBy(x => x.Name))
foreach (var packageGroupKey in packages.Where(x => !x.IsPlatformPackage).GroupBy(x => x.Name).Select(packageGroup => packageGroup.Key))
{
if (!ModuleManifest.Dependencies.Any(dependency => HasNameMatch(packageGroup.Key, dependency.Id)))
if (!ModuleManifest.Dependencies.Any(dependency => HasNameMatch(packageGroupKey, dependency.Id)))
{
result.Add($"Dependency in module.manifest is missing. Package name: {packageGroup.Key}");
result.Add($"Dependency in module.manifest is missing. Package name: {packageGroupKey}");
}
}

return result;
}

private bool HasNameMatch(string packageName, string dependencyName)
private static bool HasNameMatch(string packageName, string dependencyName)
{
var match = ModuleNameRegEx().Match(packageName);
return match.Groups.Values.Any(x => x.Value == dependencyName);
Expand Down

0 comments on commit b753f5f

Please sign in to comment.