Skip to content

Commit

Permalink
feat: better table format
Browse files Browse the repository at this point in the history
  • Loading branch information
Szandor72 committed Nov 22, 2023
1 parent a35d113 commit 9eb5825
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions scripts/ci/parse-scan-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,32 @@ async function createGithubTable(jsonFilePath) {
const dataArray = JSON.parse(jsonData);
const flattenedData = flattenJsonData(dataArray);

// Generating headers from the keys of the first object in flattenedData
const headers = Object.keys(flattenedData[0]).map(key => ({ data: key, header: true }));
// Filtering out unwanted headers and transforming ruleName
const headers = Object.keys(flattenedData[0]).reduce(
(acc, key) => {
if (!['endLine', 'endColumn', 'url'].includes(key)) {
acc.push({ data: key, header: true });
}
return acc;
},
[{ data: ':x:', header: true }],
); // Adding extra column for red X

// Generating table rows from flattenedData
const tableRows = flattenedData.map(row => Object.values(row).map(cell => cell.toString()));
// Generating table rows
const tableRows = flattenedData.map(row => {
const rowValues = Object.entries(row).reduce(
(acc, [key, value]) => {
if (key === 'ruleName') {
acc.push(`[${value}](${row.url})`); // Transforming ruleName into a Markdown link
} else if (!['endLine', 'endColumn', 'url'].includes(key)) {
acc.push(value.toString());
}
return acc;
},
[':x:'],
); // Adding red X in each row
return rowValues;
});

// Creating the GitHub table
await core.summary
Expand Down

0 comments on commit 9eb5825

Please sign in to comment.