@@ -110,12 +110,7 @@ export class RuleResultRecombinator {
110110 private static constructXml ( results : RuleResult [ ] ) : string {
111111 let resultXml = `` ;
112112
113- // If the results were just an empty string, we can return it.
114- if ( results . length === 0 ) {
115- return resultXml ;
116- }
117-
118- const normalizeSeverity : boolean = results [ 0 ] . violations . length > 0 && ! ( results [ 0 ] . violations [ 0 ] . normalizedSeverity === undefined )
113+ const normalizeSeverity : boolean = results [ 0 ] ?. violations . length > 0 && ! ( results [ 0 ] ?. violations [ 0 ] . normalizedSeverity === undefined )
119114
120115 let problemCount = 0 ;
121116
@@ -188,10 +183,6 @@ export class RuleResultRecombinator {
188183 }
189184
190185 private static constructJunit ( results : RuleResult [ ] ) : string {
191- // If there are no results, we can just return an empty string.
192- if ( ! results || results . length === 0 ) {
193- return '' ;
194- }
195186
196187 // Otherwise, we'll need to start constructing our JUnit XML. To do that, we'll need a map from file names to
197188 // lists of the <failure> tags generated from violations found in the corresponding file.
@@ -279,10 +270,6 @@ URL: ${url}`;
279270 }
280271
281272 private static constructTable ( results : RuleResult [ ] ) : RecombinedData {
282- // If the results were just an empty string, we can return it.
283- if ( results . length === 0 ) {
284- return '' ;
285- }
286273 const columns = this . violationsAreDfa ( results )
287274 ? [ 'Source Location' , 'Sink Location' , 'Description' , 'Category' , 'URL' ]
288275 : [ 'Location' , 'Description' , 'Category' , 'URL' ] ;
@@ -341,10 +328,6 @@ URL: ${url}`;
341328 }
342329
343330 private static constructJson ( results : RuleResult [ ] , verboseViolations = false ) : string {
344- if ( results . length === 0 ) {
345- return '' ;
346- }
347-
348331 if ( verboseViolations ) {
349332 const resultsVerbose = JSON . parse ( JSON . stringify ( results ) ) as RuleResult [ ] ;
350333 for ( const result of resultsVerbose ) {
@@ -363,12 +346,7 @@ URL: ${url}`;
363346 }
364347
365348 private static async constructHtml ( results : RuleResult [ ] , verboseViolations = false ) : Promise < string > {
366- // If the results were just an empty string, we can return it.
367- if ( results . length === 0 ) {
368- return '' ;
369- }
370-
371- const normalizeSeverity : boolean = results [ 0 ] . violations . length > 0 && ! ( results [ 0 ] . violations [ 0 ] . normalizedSeverity === undefined ) ;
349+ const normalizeSeverity : boolean = results [ 0 ] ?. violations . length > 0 && ! ( results [ 0 ] ?. violations [ 0 ] . normalizedSeverity === undefined ) ;
372350 const isDfa = this . violationsAreDfa ( results ) ;
373351
374352
@@ -434,12 +412,8 @@ URL: ${url}`;
434412 }
435413
436414 private static async constructCsv ( results : RuleResult [ ] ) : Promise < string > {
437- // If the results were just an empty list, we can return an empty string
438- if ( results . length === 0 ) {
439- return '' ;
440- }
441415 const isDfa : boolean = this . violationsAreDfa ( results ) ;
442- const normalizeSeverity : boolean = results [ 0 ] . violations . length > 0 && ! ( results [ 0 ] . violations [ 0 ] . normalizedSeverity === undefined )
416+ const normalizeSeverity : boolean = results [ 0 ] ? .violations . length > 0 && ! ( results [ 0 ] ? .violations [ 0 ] . normalizedSeverity === undefined )
443417
444418 const csvRows = [ ] ;
445419 // There will always be columns for the problem counter and the severity.
0 commit comments