Skip to content

Commit

Permalink
Move Set scope to avoid cross-root conflicts (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoRojo authored Jan 19, 2024
1 parent 9ea2b3c commit 3aa0f06
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class RustCliDetector : FileComponentDetector, IExperimentalDetector
{
private readonly ICommandLineInvocationService cliService;

private readonly HashSet<string> visitedDependencies = new();

/// <summary>
/// Initializes a new instance of the <see cref="RustCliDetector"/> class.
/// </summary>
Expand Down Expand Up @@ -104,7 +102,9 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
return;
}

this.TraverseAndRecordComponents(processRequest.SingleFileComponentRecorder, componentStream.Location, graph, root, null, null, packages);
HashSet<string> visitedDependencies = new();

this.TraverseAndRecordComponents(processRequest.SingleFileComponentRecorder, componentStream.Location, graph, root, null, null, packages, visitedDependencies);
}
catch (InvalidOperationException e)
{
Expand All @@ -128,6 +128,7 @@ private void TraverseAndRecordComponents(
DetectedComponent parent,
Dep depInfo,
IReadOnlyDictionary<string, (string Authors, string License)> packagesMetadata,
ISet<string> visitedDependencies,
bool explicitlyReferencedDependency = false)
{
try
Expand Down Expand Up @@ -156,10 +157,10 @@ private void TraverseAndRecordComponents(
foreach (var dep in node.Deps)
{
var componentKey = $"{detectedComponent.Component.Id}{dep.Pkg}";
if (!this.visitedDependencies.Contains(componentKey))
if (!visitedDependencies.Contains(componentKey))
{
this.visitedDependencies.Add(componentKey);
this.TraverseAndRecordComponents(recorder, location, graph, dep.Pkg, detectedComponent, dep, packagesMetadata, parent == null);
visitedDependencies.Add(componentKey);
this.TraverseAndRecordComponents(recorder, location, graph, dep.Pkg, detectedComponent, dep, packagesMetadata, visitedDependencies, parent == null);
}
}
}
Expand Down

0 comments on commit 3aa0f06

Please sign in to comment.