1- namespace Microsoft . ComponentDetection . Detectors . Go ;
1+ namespace Microsoft . ComponentDetection . Detectors . Go ;
22
33using System ;
44using System . Collections . Generic ;
@@ -53,6 +53,9 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
5353 {
5454 var singleFileComponentRecorder = processRequest . SingleFileComponentRecorder ;
5555 var file = processRequest . ComponentStream ;
56+ using var record = new GoGraphTelemetryRecord ( ) ;
57+ record . WasGoCliDisabled = false ;
58+ record . WasGoFallbackStrategyUsed = false ;
5659
5760 var projectRootDirectory = Directory . GetParent ( file . Location ) ;
5861 if ( this . projectRoots . Any ( path => projectRootDirectory . FullName . StartsWith ( path ) ) )
@@ -65,10 +68,11 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
6568 {
6669 if ( ! this . IsGoCliManuallyDisabled ( ) )
6770 {
68- wasGoCliScanSuccessful = await this . UseGoCliToScanAsync ( file . Location , singleFileComponentRecorder ) ;
71+ wasGoCliScanSuccessful = await this . UseGoCliToScanAsync ( file . Location , singleFileComponentRecorder , record ) ;
6972 }
7073 else
7174 {
75+ record . WasGoCliDisabled = true ;
7276 this . Logger . LogInformation ( "Go cli scan was manually disabled, fallback strategy performed." +
7377 " More info: https://github.com/microsoft/component-detection/blob/main/docs/detectors/go.md#fallback-detection-strategy" ) ;
7478 }
@@ -85,6 +89,7 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
8589 }
8690 else
8791 {
92+ record . WasGoFallbackStrategyUsed = true ;
8893 var fileExtension = Path . GetExtension ( file . Location ) . ToUpperInvariant ( ) ;
8994 switch ( fileExtension )
9095 {
@@ -112,11 +117,10 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
112117 }
113118
114119 [ SuppressMessage ( "Maintainability" , "CA1508:Avoid dead conditional code" , Justification = "False positive" ) ]
115- private async Task < bool > UseGoCliToScanAsync ( string location , ISingleFileComponentRecorder singleFileComponentRecorder )
120+ private async Task < bool > UseGoCliToScanAsync ( string location , ISingleFileComponentRecorder singleFileComponentRecorder , GoGraphTelemetryRecord record )
116121 {
117- using var record = new GoGraphTelemetryRecord ( ) ;
118122 record . WasGraphSuccessful = false ;
119-
123+ record . WasGoCliNotFound = false ;
120124 var projectRootDirectory = Directory . GetParent ( location ) ;
121125 record . ProjectRoot = projectRootDirectory . FullName ;
122126
@@ -126,6 +130,7 @@ private async Task<bool> UseGoCliToScanAsync(string location, ISingleFileCompone
126130 if ( ! isGoAvailable )
127131 {
128132 this . Logger . LogInformation ( "Go CLI was not found in the system" ) ;
133+ record . WasGoCliNotFound = true ;
129134 return false ;
130135 }
131136
0 commit comments