|
1 | 1 | /**
|
2 |
| - * Copyright 2024 IBM Corporation. |
| 2 | + * Copyright 2024 - 2025 IBM Corporation. |
3 | 3 | * SPDX-License-Identifier: Apache2.0
|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | const MarkdownTable = require('../markdown-table');
|
7 | 7 |
|
8 |
| -function getTable({ error, warning }) { |
9 |
| - const table = new MarkdownTable( |
10 |
| - 'Rule', |
11 |
| - 'Message', |
12 |
| - 'Path', |
13 |
| - 'Line', |
14 |
| - 'Severity' |
15 |
| - ); |
| 8 | +function getTables(violations) { |
| 9 | + let tableOutput = ''; |
| 10 | + for (const severity of ['error', 'warning']) { |
| 11 | + for (const { message, path, rule, line } of violations[severity].results) { |
| 12 | + const table = new MarkdownTable('Rule', rule); |
| 13 | + table.addRow('Message', message); |
| 14 | + table.addRow('Path', path.join('.')); |
| 15 | + table.addRow('Line', line); |
| 16 | + table.addRow('Severity', severity); |
16 | 17 |
|
17 |
| - error.results.forEach(({ message, path, rule, line }) => { |
18 |
| - table.addRow(rule, message, path.join('.'), line, 'error'); |
19 |
| - }); |
| 18 | + tableOutput += `${table.render()}\n\n`; |
| 19 | + } |
| 20 | + } |
20 | 21 |
|
21 |
| - warning.results.forEach(({ message, path, rule, line }) => { |
22 |
| - table.addRow(rule, message, path.join('.'), line, 'warning'); |
23 |
| - }); |
24 |
| - |
25 |
| - return table.render(); |
| 22 | + // Remove the final newline characters from the string. |
| 23 | + return tableOutput.trim(); |
26 | 24 | }
|
27 | 25 |
|
28 |
| -module.exports = getTable; |
| 26 | +module.exports = getTables; |
0 commit comments