DeepRegNet/DeepReg

View on GitHub

Showing 113 of 113 total issues

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

    def __init__(
Severity: Major
Found in deepreg/model/backbone/u_net.py - About 2 hrs to fix

    File image.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Provide different loss or metrics classes for images."""
    import tensorflow as tf
    
    from deepreg.constant import EPS
    from deepreg.loss.kernel import gaussian_kernel1d_size as gaussian_kernel1d
    Severity: Minor
    Found in deepreg/loss/image.py - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      for folder in cases_list[num_test:]:
          source = os.path.join(path_to_data, folder)
          destination = os.path.join(path_to_data, "train")
          shutil.move(source, destination)
      Severity: Major
      Found in demos/paired_mrus_brain/demo_data.py and 1 other location - About 2 hrs to fix
      demos/paired_mrus_brain/demo_data.py on lines 86..89

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 50.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      for folder in cases_list[:num_test]:
          source = os.path.join(path_to_data, folder)
          destination = os.path.join(path_to_data, "test")
          shutil.move(source, destination)
      Severity: Major
      Found in demos/paired_mrus_brain/demo_data.py and 1 other location - About 2 hrs to fix
      demos/paired_mrus_brain/demo_data.py on lines 90..93

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 50.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      filenames_indices = list(
          set([int(fn.split("/")[-1].split("_")[0]) for fn in filenames_all])
      Severity: Major
      Found in demos/grouped_mr_heart/demo_data.py and 1 other location - About 1 hr to fix
      demos/unpaired_ct_abdomen/demo_data.py on lines 23..24

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      filenames_indices = list(
          set([int(fn.split("/")[-1].split(".")[0]) for fn in filenames_all])
      Severity: Major
      Found in demos/unpaired_ct_abdomen/demo_data.py and 1 other location - About 1 hr to fix
      demos/grouped_mr_heart/demo_data.py on lines 24..25

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 49.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      def gif_tile_slices(img_paths, save_path=None, size=(2, 2), fname=None, interval=50):
          """
          Creates tiled gif over slices of multiple images.
      
          :param img_paths: list or comma separated string of image paths
      Severity: Minor
      Found in deepreg/vis.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

      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/unpaired_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

      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

      Function build_layers has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def build_layers(
      Severity: Major
      Found in deepreg/model/backbone/u_net.py - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if "insp" in file:
                    source = file
                    destination = os.path.join(path_to_train, "fixed_" + suffix)
                    shutil.move(source, destination)
        Severity: Major
        Found in demos/unpaired_ct_lung/demo_data.py and 1 other location - About 1 hr to fix
        demos/unpaired_ct_lung/demo_data.py on lines 82..85

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    if "T1" in file:
                        source = os.path.join(
                            project_dir, data_folder, folder, sub_folder, file
                        )
                        destination = os.path.join(
        Severity: Major
        Found in demos/paired_mrus_brain/demo_data.py and 1 other location - About 1 hr to fix
        demos/paired_mrus_brain/demo_data.py on lines 157..164

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    elif "US" in file:
                        source = os.path.join(
                            project_dir, data_folder, folder, sub_folder, file
                        )
                        destination = os.path.join(
        Severity: Major
        Found in demos/paired_mrus_brain/demo_data.py and 1 other location - About 1 hr to fix
        demos/paired_mrus_brain/demo_data.py on lines 149..156

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function get_inter_sample_indices has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_inter_sample_indices(self) -> list:
                """
                Calculate the sample indices for inter-group sampling
                The index to identify a sample is (group1, image1, group2, image2), means
        
        
        Severity: Minor
        Found in deepreg/dataset/loader/grouped_loader.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if "exp" in file:
                    source = file
                    destination = os.path.join(path_to_train, "moving_" + suffix)
                    shutil.move(source, destination)
        Severity: Major
        Found in demos/unpaired_ct_lung/demo_data.py and 1 other location - About 1 hr to fix
        demos/unpaired_ct_lung/demo_data.py on lines 78..81

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            def __init__(
        Severity: Major
        Found in deepreg/model/backbone/local_net.py - About 1 hr to fix

          Function build_decode_layers has 12 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def build_decode_layers(
          Severity: Major
          Found in deepreg/model/backbone/u_net.py - About 1 hr to fix

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if g_idx < num_train:  # train
                    fidx = 0
                elif g_idx < (num_train + num_val):  # val
                    fidx = 1
                else:  # test
            Severity: Major
            Found in demos/grouped_mr_heart/demo_data.py and 2 other locations - About 1 hr to fix
            demos/grouped_mask_prostate_longitudinal/demo_data.py on lines 78..83
            demos/unpaired_ct_abdomen/demo_data.py on lines 62..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 43.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if pos_group < num_train:  # train
                    idf = 0
                elif pos_group < (num_train + num_val):  # val
                    idf = 1
                else:  # test
            Severity: Major
            Found in demos/grouped_mask_prostate_longitudinal/demo_data.py and 2 other locations - About 1 hr to fix
            demos/grouped_mr_heart/demo_data.py on lines 97..102
            demos/unpaired_ct_abdomen/demo_data.py on lines 62..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 43.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if idx < num_train:  # train
                    fidx = 0
                elif idx < (num_train + num_val):  # val
                    fidx = 1
                else:  # test
            Severity: Major
            Found in demos/unpaired_ct_abdomen/demo_data.py and 2 other locations - About 1 hr to fix
            demos/grouped_mask_prostate_longitudinal/demo_data.py on lines 78..83
            demos/grouped_mr_heart/demo_data.py on lines 97..102

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 43.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language