From 9212f3604d2f06f397c6671578f2e87fe960e070 Mon Sep 17 00:00:00 2001 From: Amndeep Singh Mann Date: Sat, 27 Jul 2024 20:39:12 -0400 Subject: [PATCH] simplified skip message logic Signed-off-by: Amndeep Singh Mann --- libs/hdf-converters/src/gosec-mapper.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libs/hdf-converters/src/gosec-mapper.ts b/libs/hdf-converters/src/gosec-mapper.ts index 72ccd887ab..68d8765751 100644 --- a/libs/hdf-converters/src/gosec-mapper.ts +++ b/libs/hdf-converters/src/gosec-mapper.ts @@ -38,18 +38,18 @@ function formatSkipMessage(input: Record): string { if (`${suppressions}` === 'null') { return 'N/A'; } - // If test is skipped - let skipMessage = ''; - if (Array.isArray(suppressions)) { - suppressions.map((suppression) => { - // If a justification is given, report; otherwise, report that none is given - skipMessage = skipMessage.concat( - `${suppression.justification ? suppression.justification : 'No reason provided'} (${suppression.kind}) ` - ); - }); - } - return skipMessage.trim(); + // If test is skipped and there are no justifications, report that none are given + if (!Array.isArray(suppressions)) { + return ''; + } + // otherwise, supply the justifications + return suppressions + .map( + (suppression) => + `${suppression.justification ? suppression.justification : 'No reason provided'} (${suppression.kind})` + ) + .join(' '); } // Report gosec rule violation and violation location