Skip to content

Commit c3ff1b2

Browse files
authored
Merge pull request #392 from siemens/release/removedcod
feat: removed unused code
2 parents 3e89bdd + f6abc64 commit c3ff1b2

File tree

1 file changed

+1
-89
lines changed

1 file changed

+1
-89
lines changed

src/LCT.Common/CommonHelper.cs

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -961,95 +961,7 @@ public static void AddSiemensDirectProperty(ref Bom bom)
961961
}
962962
bom.Components = bomComponentsList;
963963
}
964-
/// <summary>
965-
/// Enriches cdxgen components by merging existing properties from already discovered BOM components.
966-
/// </summary>
967-
/// <param name="componentsForBOM">
968-
/// Reference to the list of components already discovered (e.g., from lock/package files).
969-
/// Properties from these components will be used to enrich the incoming cdxgen components.
970-
/// </param>
971-
/// <param name="cdxComponents">
972-
/// Components parsed from the cdxgen-generated CycloneDX BOM that need to be enriched.
973-
/// </param>
974-
/// <remarks>
975-
/// Matching strategy:
976-
/// - First attempts match by PURL (case-insensitive).
977-
/// - Falls back to Name+Version key when PURL is unavailable.
978-
/// For matched components, existing properties are cloned into the cdxgen component.
979-
/// </remarks>
980-
private static void EnrichComponentsFromCdxGen(ref List<Component> componentsForBOM, List<Component> cdxComponents)
981-
{
982-
983-
var byPurl = new Dictionary<string, Component>(StringComparer.OrdinalIgnoreCase);
984-
foreach (var c in componentsForBOM.Where(c => !string.IsNullOrEmpty(c.Purl)))
985-
{
986-
byPurl[c.Purl] = c;
987-
}
988-
989-
var byNameVer = new Dictionary<string, Component>(StringComparer.OrdinalIgnoreCase);
990-
foreach (var c in componentsForBOM.Where(c => !string.IsNullOrEmpty(c.Name) && !string.IsNullOrEmpty(c.Version)))
991-
{
992-
var key = $"{c.Name}|{c.Version}";
993-
byNameVer[key] = c;
994-
}
995-
996-
foreach (var cdx in cdxComponents)
997-
{
998-
MergeExistingPropertiesIntoCdx(cdx, byPurl, byNameVer);
999-
}
1000-
}
1001-
1002-
/// <summary>
1003-
/// Merges existing component properties into a cdxgen component by matching against already discovered BOM components.
1004-
/// </summary>
1005-
/// <param name="cdx">
1006-
/// The cdxgen component to enrich with properties cloned from a matching existing component.
1007-
/// </param>
1008-
/// <param name="byPurl">
1009-
/// Lookup dictionary of existing components keyed by PURL (case-insensitive).
1010-
/// </param>
1011-
/// <param name="byNameVer">
1012-
/// Lookup dictionary of existing components keyed by "Name|Version" (case-insensitive) for cases where PURL is unavailable.
1013-
/// </param>
1014-
/// <remarks>
1015-
/// Matching strategy:
1016-
/// - Prefer matching by PURL when available.
1017-
/// - Fallback to matching by Name and Version.
1018-
/// If a match is found and the existing component has properties, those properties are cloned into the target <paramref name="cdx"/>.
1019-
/// Otherwise, ensures <paramref name="cdx"/> has a non-null properties list.
1020-
/// </remarks>
1021-
private static void MergeExistingPropertiesIntoCdx(
1022-
Component cdx,
1023-
Dictionary<string, Component> byPurl,
1024-
Dictionary<string, Component> byNameVer)
1025-
{
1026-
Component existing = null;
1027-
1028-
if (!string.IsNullOrEmpty(cdx.Purl) && byPurl.TryGetValue(cdx.Purl, out var matchByPurl))
1029-
{
1030-
existing = matchByPurl;
1031-
}
1032-
else
1033-
{
1034-
var key = (!string.IsNullOrEmpty(cdx.Name) && !string.IsNullOrEmpty(cdx.Version))
1035-
? $"{cdx.Name}|{cdx.Version}"
1036-
: null;
1037-
1038-
if (key != null && byNameVer.TryGetValue(key, out var matchByNameVer))
1039-
{
1040-
existing = matchByNameVer;
1041-
}
1042-
}
1043-
1044-
if (existing != null && existing.Properties != null && existing.Properties.Count > 0)
1045-
{
1046-
cdx.Properties = [.. existing.Properties.Select(p => new Property { Name = p.Name, Value = p.Value })];
1047-
}
1048-
else
1049-
{
1050-
cdx.Properties ??= new List<Property>();
1051-
}
1052-
}
964+
1053965
#endregion
1054966

1055967

0 commit comments

Comments
 (0)