Skip to content

Commit

Permalink
Add deprecation visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolev92 committed Sep 12, 2023
1 parent 3897049 commit 9d160a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Common/IPackageDependencyNodeDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public interface IPackageDependencyNodeDecorator
{
Task DecorateAsync(PackageDependencyNode dependencyNode, CancellationToken cancellationToken);
}
}
}

Check warning on line 7 in src/Common/IPackageDependencyNodeDecorator.cs

View workflow job for this annotation

GitHub Actions / build

Fix formatting

Check warning on line 7 in src/Common/IPackageDependencyNodeDecorator.cs

View workflow job for this annotation

GitHub Actions / build

Fix formatting
35 changes: 29 additions & 6 deletions src/DependencyVisualizerTool/DGMLDependencyVisualizerTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public static XDocument TransGraphToDGMLXDocument(PackageDependencyGraph graph,
id: firstNode.Identity.ToString(),
label: firstNode.Identity.ToString(),
type: firstNode.Identity.Type,
isVulnerable: firstNode.Identity.Vulnerable);
isVulnerable: firstNode.Identity.Vulnerable,
isDeprecated: firstNode.Identity.Deprecated);
nodes.Add(firstNode.Identity.ToString(), firstNodeDGML);

while (queue.Count > 0)
Expand All @@ -49,7 +50,8 @@ public static XDocument TransGraphToDGMLXDocument(PackageDependencyGraph graph,
id: child.Item1.Identity.ToString(),
label: child.Item1.Identity.ToString(),
type: child.Item1.Identity.Type,
child.Item1.Identity.Vulnerable);
child.Item1.Identity.Vulnerable,
child.Item1.Identity.Deprecated);
nodes.Add(child.Item1.Identity.ToString(), currentDGML);
}
}
Expand Down Expand Up @@ -88,8 +90,18 @@ from item in links
new XAttribute("StrokeThickness", "1")),
new XElement(XName.Get("Category", DGMLxmlns),
new XAttribute("Id", "VulnerablePackage"),
new XAttribute("Background", "Red"),
new XAttribute("StrokeThickness", "1"))))
new XAttribute("Background", "None"),
new XAttribute("StrokeThickness", "4"),
new XAttribute("Stroke", "Red")),
new XElement(XName.Get("Category", DGMLxmlns),
new XAttribute("Id", "DeprecatedPackage"),
new XAttribute("Background", "Yellow"),
new XAttribute("StrokeThickness", "1")),
new XElement(XName.Get("Category", DGMLxmlns),
new XAttribute("Id", "VulnerableAndDeprecatedPackage"),
new XAttribute("Background", "Yellow"),
new XAttribute("StrokeThickness", "4"),
new XAttribute("Stroke", "Red"))))
);
return document;
}
Expand All @@ -102,11 +114,22 @@ private class DGMLNode : IEquatable<DGMLNode>

public string Category { get; set; }

public DGMLNode(string id, string label, DependencyType type, bool isVulnerable)
public DGMLNode(string id, string label, DependencyType type, bool isVulnerable, bool isDeprecated)
{
this.Id = id;
this.Label = label;
this.Category = isVulnerable ? "VulnerablePackage" : type.ToString();
this.Category = GetCategory(type, isVulnerable, isDeprecated);
}

private static string GetCategory(DependencyType type, bool isVulnerable, bool isDeprecated)
{
return isVulnerable && isDeprecated ?
"VulnerableAndDeprecatedPackage" :
isVulnerable ?
"VulnerablePackage" :
isDeprecated ?
"DeprecatedPackage" :
type.ToString();
}

public bool Equals(DGMLNode other)

Check warning on line 135 in src/DependencyVisualizerTool/DGMLDependencyVisualizerTool.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'other' of 'bool DGMLNode.Equals(DGMLNode other)' doesn't match implicitly implemented member 'bool IEquatable<DGMLNode>.Equals(DGMLNode? other)' (possibly because of nullability attributes).

Check warning on line 135 in src/DependencyVisualizerTool/DGMLDependencyVisualizerTool.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'other' of 'bool DGMLNode.Equals(DGMLNode other)' doesn't match implicitly implemented member 'bool IEquatable<DGMLNode>.Equals(DGMLNode? other)' (possibly because of nullability attributes).
Expand Down

0 comments on commit 9d160a5

Please sign in to comment.