Skip to content

Commit

Permalink
fix: Spacing for issue descriptions with custom rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ofekatr committed Aug 24, 2022
1 parent 42d4720 commit 29b2fdb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/lib/formatters/iac-output/v2/issues-list/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/jest/acceptance/iac/output-formats/text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
});
});
});
Expand Down

0 comments on commit 29b2fdb

Please sign in to comment.