DeepRegNet/DeepReg

View on GitHub
demos/paired_ct_lung/demo_data.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function move_test_cases_into_correct_path has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def move_test_cases_into_correct_path(test_cases, path_to_train, path_to_test):
        folder_names = os.listdir(path_to_train)
        os.chdir(path_to_train)
        for case in test_cases:
            for folder in folder_names:
Severity: Minor
Found in demos/paired_ct_lung/demo_data.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                    if case in file:
                        os.chdir(os.path.join(path_to_train, folder))
                        source = file
                        destination = os.path.join(path_to_test, folder)
                        shutil.move(source, destination)
Severity: Major
Found in demos/paired_ct_lung/demo_data.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if np.max(im_data) > 255.0:
                        im_data = ((im_data + 285) / (3770 + 285)) * 255.0  # rescale image
                        img = nib.Nifti1Image(im_data, affine=None)
                        nib.save(img, os.path.join(data_dir, folder, subfolder, file))
                        if np.max(img.dataobj) > 255.0:
    Severity: Major
    Found in demos/paired_ct_lung/demo_data.py - About 45 mins to fix

      Function move_files_into_correct_path has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def move_files_into_correct_path(
      Severity: Minor
      Found in demos/paired_ct_lung/demo_data.py - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status