Skip to content

Commit e1f26b9

Browse files
committed
fix printing of report urls
1 parent 2736c04 commit e1f26b9

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

cycode/cli/printers/tables/sca_table_printer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _print_results(self, local_scan_results: List['LocalScanResult']) -> None:
5151
self._enrich_table_with_values(table, detection)
5252

5353
self._print_summary_issues(len(detections), self._get_title(policy_id))
54-
click.echo(table.get_table().draw())
54+
self._print_table(table)
5555

5656
self._print_report_urls(local_scan_results)
5757

@@ -116,9 +116,12 @@ def _enrich_table_with_values(table: Table, detection: Detection) -> None:
116116

117117
@staticmethod
118118
def _print_report_urls(local_scan_results: List['LocalScanResult']) -> None:
119+
report_urls = [scan_result.report_url for scan_result in local_scan_results if scan_result.report_url]
120+
if not report_urls:
121+
return
122+
119123
click.echo('Report URLs:')
120-
for local_scan_result in local_scan_results:
121-
report_url = local_scan_result.report_url if local_scan_result.report_url else 'N/A'
124+
for report_url in report_urls:
122125
click.echo(f'- {report_url}')
123126

124127
@staticmethod

cycode/cli/printers/tables/table_printer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _print_results(self, local_scan_results: List['LocalScanResult']) -> None:
6565
table.set(SCAN_ID_COLUMN, local_scan_result.scan_id)
6666
self._enrich_table_with_values(table, detection, document_detections.document)
6767

68-
click.echo(table.get_table().draw())
68+
self._print_table(table)
6969

7070
def _get_table(self) -> Table:
7171
table = Table()
@@ -76,7 +76,6 @@ def _get_table(self) -> Table:
7676
table.add(LINE_NUMBER_COLUMN)
7777
table.add(COLUMN_NUMBER_COLUMN)
7878
table.add(SCAN_ID_COLUMN)
79-
table.add(REPORT_URL_COLUMN)
8079

8180
if self._is_git_repository():
8281
table.add(COMMIT_SHA_COLUMN)
@@ -86,6 +85,9 @@ def _get_table(self) -> Table:
8685
table.add(VIOLATION_LENGTH_COLUMN)
8786
table.add(VIOLATION_COLUMN)
8887

88+
if self.context.obj.get('report'):
89+
table.add(REPORT_URL_COLUMN)
90+
8991
return table
9092

9193
def _enrich_table_with_values(self, table: Table, detection: Detection, document: Document) -> None:

cycode/cli/printers/tables/table_printer_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
if TYPE_CHECKING:
1111
from cycode.cli.models import LocalScanResult
12+
from cycode.cli.printers.tables.table import Table
1213

1314

1415
class TablePrinterBase(PrinterBase, abc.ABC):
@@ -36,3 +37,7 @@ def _is_git_repository(self) -> bool:
3637
@abc.abstractmethod
3738
def _print_results(self, local_scan_results: List['LocalScanResult']) -> None:
3839
raise NotImplementedError
40+
41+
@staticmethod
42+
def _print_table(table: 'Table') -> None:
43+
click.echo(table.get_table().draw())

0 commit comments

Comments
 (0)