DeepRegNet/DeepReg

View on GitHub

Showing 89 of 113 total issues

Function get_dataset_and_preprocess has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get_dataset_and_preprocess(
Severity: Minor
Found in deepreg/dataset/loader/interface.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if np.sum((values - values_init) ** 2) > 0:
                        break
    
    
    Severity: Major
    Found in demos/unpaired_mr_brain/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 gif_warp has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def gif_warp(
        Severity: Minor
        Found in deepreg/vis.py - About 45 mins to fix

          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Minor
          Found in deepreg/dataset/loader/unpaired_loader.py - About 45 mins to fix

            Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Minor
            Found in deepreg/loss/image.py - About 45 mins to fix

              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(
              Severity: Minor
              Found in deepreg/dataset/preprocess.py - About 45 mins to fix

                Function build_up_sampling_block has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def build_up_sampling_block(
                Severity: Minor
                Found in deepreg/model/backbone/local_net.py - About 45 mins to fix

                  Function get_dataset_and_preprocess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_dataset_and_preprocess(
                          self,
                          training: bool,
                          batch_size: int,
                          repeat: bool,
                  Severity: Minor
                  Found in deepreg/dataset/loader/interface.py - About 45 mins 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

                  Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(
                  Severity: Minor
                  Found in deepreg/loss/label.py - About 45 mins to fix

                    Function build_up_sampling_block has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def build_up_sampling_block(
                    Severity: Minor
                    Found in deepreg/model/backbone/u_net.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      if "T1" in file:
                                          arr = nib.load(
                                              os.path.join(path_to_data, folder, sub_folder, file)
                                          ).get_data()
                                          img = nib.Nifti1Image(arr, affine=np.eye(4))
                      Severity: Major
                      Found in demos/paired_mrus_brain/demo_data.py - About 45 mins to fix

                        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/unpaired_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/unpaired_ct_lung/demo_data.py - About 45 mins to fix

                            Function predict_on_dataset has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def predict_on_dataset(
                            Severity: Minor
                            Found in deepreg/predict.py - About 45 mins to fix

                              Function remove_prefix_suffix has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def remove_prefix_suffix(
                                  x: str, prefix: Union[str, List[str]], suffix: Union[str, List[str]]
                              ) -> str:
                                  """
                                  Remove the prefix and suffix from a string,
                              Severity: Minor
                              Found in deepreg/dataset/loader/util.py - About 45 mins 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

                              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def __init__(
                              Severity: Minor
                              Found in deepreg/loss/label.py - About 45 mins to fix

                                Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def __init__(
                                Severity: Minor
                                Found in deepreg/model/layer.py - About 45 mins to fix

                                  Function sample_image_label has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def sample_image_label(
                                  Severity: Minor
                                  Found in deepreg/dataset/loader/interface.py - About 45 mins to fix

                                    Function get_data_loader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    def get_data_loader(data_config: dict, split: str) -> Optional[DataLoader]:
                                        """
                                        Return the corresponding data loader.
                                    
                                        Can't be placed in the same file of loader interfaces as it causes import cycle.
                                    Severity: Minor
                                    Found in deepreg/dataset/load.py - About 45 mins 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language