Skip to content

Commit 6fb939e

Browse files
Refactoring method to reduce its Cognitive Complexity from 16 to the 15 allowed.
1 parent ca6b8e5 commit 6fb939e

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

utils/investigation_dataset.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,25 @@ def complete_dataset_with_args(
396396
failure_information["failure reasons"],
397397
)
398398

399+
self.process_polyps(polyp_information, polyp_intervention, polyp_histology)
400+
401+
logging.info("Saving the investigation dataset")
402+
InvestigationDatasetsPage(self.page).check_dataset_complete_checkbox()
403+
InvestigationDatasetsPage(self.page).click_save_dataset_button()
404+
405+
def process_polyps(
406+
self,
407+
polyp_information: Optional[list] = None,
408+
polyp_intervention: Optional[list] = None,
409+
polyp_histology: Optional[list] = None,
410+
) -> None:
411+
"""
412+
This method is in charge of processing any polyps to be added to the dataset.
413+
Args:
414+
polyp_information (Optional[list]): An optional list containing the polyp information to be filled in the form.
415+
polyp_intervention (Optional[list]): An optional list containing the polyp intervention to be filled in the form.
416+
polyp_histology (Optional[list]): An optional list containing the polyp histology to be filled in the form.
417+
"""
399418
# Polyp Information
400419
if polyp_information is not None:
401420
for polyp_number, polyp_info in enumerate(polyp_information, start=1):
@@ -428,10 +447,6 @@ def complete_dataset_with_args(
428447
logging.info(f"Filling out polyp {polyp_number} histology")
429448
self.fill_polyp_x_histology(polyp_histology_info, polyp_number)
430449

431-
logging.info("Saving the investigation dataset")
432-
InvestigationDatasetsPage(self.page).check_dataset_complete_checkbox()
433-
InvestigationDatasetsPage(self.page).click_save_dataset_button()
434-
435450
def fill_endoscopy_information(self, endoscopy_information: dict) -> None:
436451
"""
437452
Fills out the endoscopy information section of the investigation dataset.

0 commit comments

Comments
 (0)