Skip to content

Commit

Permalink
fix: make sonar happy -> reduce complexity
Browse files Browse the repository at this point in the history
Signed-off-by: Lou DeGenaro <[email protected]>
  • Loading branch information
degenaro committed Feb 6, 2024
1 parent e987665 commit f9a1eee
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions trestle/core/catalog/catalog_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,20 @@ def get_statement_part_id_map(self, label_as_key: bool) -> Dict[str, Dict[str, s
id_map = {}
for control in self.get_all_controls_from_catalog(True):
statement_part = get_item_from_list(control.parts, const.STATEMENT, lambda p: p.name)
if statement_part:
id_dict: Dict[str, str] = {}
for sub_part in as_list(statement_part.parts):
label = ControlInterface.get_label(sub_part)
# skip add to map for empty label
if label:
if label_as_key:
id_dict[label] = sub_part.id
else:
id_dict[sub_part.id] = label
if id_dict:
id_map[control.id] = id_dict
if not statement_part:
continue
id_dict: Dict[str, str] = {}
for sub_part in as_list(statement_part.parts):
label = ControlInterface.get_label(sub_part)
# skip add to map for empty label
if not label:
continue
if label_as_key:
id_dict[label] = sub_part.id
else:
id_dict[sub_part.id] = label
if id_dict:
id_map[control.id] = id_dict
return id_map

@staticmethod
Expand Down

0 comments on commit f9a1eee

Please sign in to comment.