Skip to content

Commit 9fd6c6d

Browse files
committed
reuse messages in printers
1 parent 9dea2b9 commit 9fd6c6d

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

cycode/cli/printers/printer_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616

1717

1818
class PrinterBase(ABC):
19+
NO_DETECTIONS_MESSAGE = (
20+
'[green]Good job! No issues were found!!! :clapping_hands::clapping_hands::clapping_hands:[/green]'
21+
)
22+
FAILED_SCAN_MESSAGE = (
23+
'[red]Unfortunately, Cycode was unable to complete the full scan. '
24+
'Please note that not all results may be available:[/red]'
25+
)
26+
1927
def __init__(self, ctx: typer.Context) -> None:
2028
self.ctx = ctx
2129

cycode/cli/printers/tables/table_printer_base.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,15 @@ def print_scan_results(
2929
self, local_scan_results: List['LocalScanResult'], errors: Optional[Dict[str, 'CliError']] = None
3030
) -> None:
3131
if not errors and all(result.issue_detected == 0 for result in local_scan_results):
32-
console.print(
33-
'[green]Good job! No issues were found!!! :clapping_hands::clapping_hands::clapping_hands:[/green]'
34-
)
32+
console.print(self.NO_DETECTIONS_MESSAGE)
3533
return
3634

3735
self._print_results(local_scan_results)
3836

3937
if not errors:
4038
return
4139

42-
console.print(
43-
'[red]Unfortunately, Cycode was unable to complete the full scan. '
44-
'Please note that not all results may be available:[/red]',
45-
)
40+
console.print(self.FAILED_SCAN_MESSAGE)
4641
for scan_id, error in errors.items():
4742
console.print(f'- {scan_id}: ', end='')
4843
self.print_error(error)

cycode/cli/printers/text_printer.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ def print_scan_results(
4545
self, local_scan_results: List['LocalScanResult'], errors: Optional[Dict[str, 'CliError']] = None
4646
) -> None:
4747
if not errors and all(result.issue_detected == 0 for result in local_scan_results):
48-
console.print(
49-
'[green]Good job! No issues were found!!! :clapping_hands::clapping_hands::clapping_hands:[/green]'
50-
)
48+
console.print(self.NO_DETECTIONS_MESSAGE)
5149
return
5250

5351
for local_scan_result in local_scan_results:
@@ -60,10 +58,7 @@ def print_scan_results(
6058
if not errors:
6159
return
6260

63-
console.print(
64-
'[red]Unfortunately, Cycode was unable to complete the full scan. '
65-
'Please note that not all results may be available:[/red]',
66-
)
61+
console.print(self.FAILED_SCAN_MESSAGE)
6762
for scan_id, error in errors.items():
6863
console.print(f'- {scan_id}: ', end='')
6964
self.print_error(error)

0 commit comments

Comments
 (0)