DeepRegNet/DeepReg

View on GitHub

Showing 113 of 113 total issues

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

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

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

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

      Function train has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def train(
          gpu: str,
          config_path: Union[str, List[str]],
          ckpt_path: str,
          num_workers: int = 1,
      Severity: Minor
      Found in deepreg/train.py - About 35 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

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

          with zf.open(filename) as sf, open(img_path, "wb") as df:
              shutil.copyfileobj(sf, df)
      Severity: Minor
      Found in demos/grouped_mr_heart/demo_data.py and 1 other location - About 35 mins to fix
      demos/unpaired_ct_abdomen/demo_data.py on lines 69..70

      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 33.

      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 predict has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def predict(
          gpu: str,
          ckpt_path: str,
          split: str,
          batch_size: int,
      Severity: Minor
      Found in deepreg/predict.py - About 35 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

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

          with zf.open(filename) as sf, open(filename_dst, "wb") as df:
              shutil.copyfileobj(sf, df)
      Severity: Minor
      Found in demos/unpaired_ct_abdomen/demo_data.py and 1 other location - About 35 mins to fix
      demos/grouped_mr_heart/demo_data.py on lines 54..55

      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 33.

      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 parse_label_loss has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_label_loss(loss_config: Dict) -> Dict:
          """
          Parse the label loss part in loss configuration.
      
          :param loss_config: potentially outdated config
      Severity: Minor
      Found in deepreg/config/v011.py - About 35 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 main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def main(args=None):
          """
          CLI for deepreg_vis tool.
      
          Requires ffmpeg wirter to write gif files.
      Severity: Minor
      Found in deepreg/vis.py - About 35 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

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

          os.rename(
              os.path.join(project_dir, data_folder_name, folder, "moving_images"),
              os.path.join(project_dir, data_folder_name, folder, "images"),
      Severity: Minor
      Found in demos/unpaired_ct_lung/demo_data.py and 1 other location - About 30 mins to fix
      demos/unpaired_ct_lung/demo_data.py on lines 222..224

      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 32.

      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

          os.rename(
              os.path.join(project_dir, data_folder_name, folder, "moving_labels"),
              os.path.join(project_dir, data_folder_name, folder, "labels"),
      Severity: Minor
      Found in demos/unpaired_ct_lung/demo_data.py and 1 other location - About 30 mins to fix
      demos/unpaired_ct_lung/demo_data.py on lines 218..220

      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 32.

      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 set_data_structure has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_data_structure(self):
              """
              Store the data structure in  memory so that
              we can retrieve data using data_index.
              This function sets two attributes:
      Severity: Minor
      Found in deepreg/dataset/loader/h5_loader.py - About 25 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 build_from_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_from_config(
              self, category: str, config: Dict, default_args: Optional[dict] = None
          ) -> Any:
              """
              Build a class instance from config dict.
      Severity: Minor
      Found in deepreg/registry.py - About 25 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 parse_reg_loss has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_reg_loss(loss_config: Dict) -> Dict:
          """
          Parse the regularization loss part in loss configuration.
      
          :param loss_config: potentially outdated config
      Severity: Minor
      Found in deepreg/config/v011.py - About 25 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