11from collections import defaultdict
2- from typing import TYPE_CHECKING , List , Tuple
2+ from typing import TYPE_CHECKING , List , Set , Tuple
33
44from cycode .cli .cli_types import SeverityOption
55from cycode .cli .consts import SECRET_SCAN_TYPE
1818SEVERITY_COLUMN = column_builder .build (name = 'Severity' )
1919ISSUE_TYPE_COLUMN = column_builder .build (name = 'Issue Type' )
2020FILE_PATH_COLUMN = column_builder .build (name = 'File Path' , highlight = False )
21+ LINE_NUMBER_COLUMN = column_builder .build (name = 'Line' )
22+ COLUMN_NUMBER_COLUMN = column_builder .build (name = 'Column' )
23+ VIOLATION_COLUMN = column_builder .build (name = 'Violation' , highlight = False )
24+ VIOLATION_LENGTH_COLUMN = column_builder .build (name = 'Length' )
2125SECRET_SHA_COLUMN = column_builder .build (name = 'Secret SHA' )
2226COMMIT_SHA_COLUMN = column_builder .build (name = 'Commit SHA' )
23- LINE_NUMBER_COLUMN = column_builder .build (name = 'Line Number' )
24- COLUMN_NUMBER_COLUMN = column_builder .build (name = 'Column Number' )
25- VIOLATION_LENGTH_COLUMN = column_builder .build (name = 'Violation Length' )
26- VIOLATION_COLUMN = column_builder .build (name = 'Violation' , highlight = False )
2727
2828
2929class TablePrinter (TablePrinterBase ):
@@ -37,9 +37,12 @@ def _print_results(self, local_scan_results: List['LocalScanResult']) -> None:
3737 [(detection , document_detections .document ) for detection in document_detections .detections ]
3838 )
3939
40- for detection , document in self ._sort_and_group_detections (detections_with_documents ):
40+ detections , group_separator_indexes = self ._sort_and_group_detections (detections_with_documents )
41+ for detection , document in detections :
4142 self ._enrich_table_with_values (table , detection , document )
4243
44+ table .set_group_separator_indexes (group_separator_indexes )
45+
4346 self ._print_table (table )
4447 self ._print_report_urls (local_scan_results , self .ctx .obj .get ('aggregation_report_url' ))
4548
@@ -66,9 +69,10 @@ def _sort_detections_by_file_path(
6669
6770 def _sort_and_group_detections (
6871 self , detections_with_documents : List [Tuple [Detection , Document ]]
69- ) -> List [Tuple [Detection , Document ]]:
72+ ) -> Tuple [ List [Tuple [Detection , Document ]], Set [ int ]]:
7073 """Sort detections by severity and group by file name."""
71- result = []
74+ detections = []
75+ group_separator_indexes = set ()
7276
7377 # we sort detections by file path to make persist output order
7478 sorted_detections = self ._sort_detections_by_file_path (detections_with_documents )
@@ -78,9 +82,10 @@ def _sort_and_group_detections(
7882 grouped_by_file_path [document .path ].append ((detection , document ))
7983
8084 for file_path_group in grouped_by_file_path .values ():
81- result .extend (self ._sort_detections_by_severity (file_path_group ))
85+ group_separator_indexes .add (len (detections ) - 1 ) # indexing starts from 0
86+ detections .extend (self ._sort_detections_by_severity (file_path_group ))
8287
83- return result
88+ return detections , group_separator_indexes
8489
8590 def _get_table (self ) -> Table :
8691 table = Table ()
0 commit comments