microsoft / sarif-sdk

.NET code and supporting files for working with the 'Static Analysis Results Interchange Format' (SARIF, see https://github.com/oasis-tcs/sarif-spec)
Other
191 stars 88 forks source link

* BUG: Emit `WRN997.OneOrMoreFilesSkippedDueToExceedingSizeLimit` when no valid analysis targets are detected (due to exceeding size limits). #2745

Closed michaelcfanning closed 8 months ago

michaelcfanning commented 8 months ago

This bug has burned me repeatedly so I finally fixed it. In cases where I attempt to analyze a single file, and it is too large to analysis given current configuration, the console only reports 'no valid targets found', leading me to assume I mistyped the file path or something else:

Analyzing... THREADS: 36 SPMI : error ERR997.NoValidAnalysisTargets : No valid analysis targets were specified.

Now we emit the explicit warning that one or more files were skipped, as we do in the case when we find at least one valid target:

Analyzing... THREADS: 36 SPMI : error ERR997.NoValidAnalysisTargets : No valid analysis targets were specified. SPMI : warning WRN997.OneOrMoreFilesSkippedDueToExceedingSizeLimit : 1 file(s) were skipped for analysis due to exceeding size limit (currently configured as 1024 KB). The 'max-file-size-in-kb' command-line argument can be used to increase this threshold.

Added a solid unit test for this. I was glad to see this test was easy to author, we're getting much better in that regard.