Skip to content

Commit 6962ca6

Browse files
authored
fix(experiments): tighten NPM lockfile v3 condition (#579)
1 parent 6e2d946 commit 6962ca6

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/Microsoft.ComponentDetection.Orchestrator/Experiments/Configs/NpmLockfile3Experiment.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
using Microsoft.ComponentDetection.Contracts;
44
using Microsoft.ComponentDetection.Detectors.Npm;
5+
using Microsoft.ComponentDetection.Detectors.Pnpm;
6+
using Microsoft.ComponentDetection.Detectors.Poetry;
7+
using Microsoft.ComponentDetection.Detectors.Yarn;
58

69
/// <summary>
710
/// Validating the <see cref="NpmLockfile3Detector"/>.
@@ -18,6 +21,20 @@ public class NpmLockfile3Experiment : IExperimentConfiguration
1821
public bool IsInExperimentGroup(IComponentDetector componentDetector) => componentDetector is NpmLockfile3Detector;
1922

2023
/// <inheritdoc />
21-
public bool ShouldRecord(IComponentDetector componentDetector, int numComponents) =>
22-
componentDetector is not NpmComponentDetectorWithRoots || numComponents == 0;
24+
public bool ShouldRecord(IComponentDetector componentDetector, int numComponents)
25+
{
26+
if (numComponents == 0)
27+
{
28+
return true;
29+
}
30+
31+
return componentDetector switch
32+
{
33+
NpmComponentDetectorWithRoots
34+
or PnpmComponentDetector
35+
or PoetryComponentDetector
36+
or YarnLockComponentDetector => false,
37+
_ => true,
38+
};
39+
}
2340
}

0 commit comments

Comments
 (0)