diff --git a/src/lib/formatters/iac-output/v2/issues-list/issue.ts b/src/lib/formatters/iac-output/v2/issues-list/issue.ts index 50d3b69dc1..6fea8b931c 100644 --- a/src/lib/formatters/iac-output/v2/issues-list/issue.ts +++ b/src/lib/formatters/iac-output/v2/issues-list/issue.ts @@ -77,16 +77,18 @@ function formatProperties( ? result.issue.remediation[remediationKey] : result.issue.resolve, ], - ].filter(([, val]) => !!val) as [string, string][]; + ]; const maxPropertyNameLength = Math.max( ...properties.map(([key]) => key.length), ); - return properties.map( - ([key, value]) => - `${key}: ${' '.repeat(maxPropertyNameLength - key.length)}${value}`, - ); + return properties + .filter(([, val]) => !!val) + .map( + ([key, value]) => + `${key}: ${' '.repeat(maxPropertyNameLength - key.length)}${value}`, + ); } function isValidLineNumber(lineNumber: number | undefined): boolean { diff --git a/test/jest/acceptance/iac/output-formats/text.spec.ts b/test/jest/acceptance/iac/output-formats/text.spec.ts index ac547c0382..5e9415586c 100644 --- a/test/jest/acceptance/iac/output-formats/text.spec.ts +++ b/test/jest/acceptance/iac/output-formats/text.spec.ts @@ -275,7 +275,7 @@ Target file: ${dirPath}/`); `snyk iac test ${filePath} --rules=./iac/custom-rules/custom.tar.gz`, ); - expect(stdout).toContain(`Rule: custom rule CUSTOM-1`); + expect(stdout).toContain(`Rule: custom rule CUSTOM-1`); }); }); });