fepegar/torchio

View on GitHub

Showing 105 of 105 total issues

Function _get_subjects_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_subjects_list(root, modalities):
        # The number of files for each modality is not the same
        # E.g. 581 for T1, 578 for T2
        # Let's just use the first modality as reference for now
        # I.e. only subjects with all modalities will be included
Severity: Minor
Found in src/torchio/datasets/ixi.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 check_consistent_attribute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def check_consistent_attribute(
        self,
        attribute: str,
        relative_tolerance: float = 1e-6,
        absolute_tolerance: float = 1e-6,
Severity: Minor
Found in src/torchio/data/subject.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in src/torchio/transforms/transform.py - About 1 hr to fix

    Function apply_transform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def apply_transform(self, subject: Subject) -> Subject:
            images = subject.get_images(
                intensity_only=False,
                include=self.include,
                exclude=self.exclude,
    Severity: Minor
    Found in src/torchio/transforms/lambda_transform.py - About 55 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 generate_bias_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_bias_field(
            data: TypeData,
            order: int,
            coefficients: TypeData,
        ) -> np.ndarray:
    Severity: Minor
    Found in src/torchio/transforms/augmentation/intensity/random_bias_field.py - About 55 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 apply_transform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def apply_transform(self, subject: Subject) -> Subject:
            gamma = self.gamma
            for name, image in self.get_images_dict(subject).items():
                if self.arguments_are_dict():
                    assert isinstance(self.gamma, dict)
    Severity: Minor
    Found in src/torchio/transforms/augmentation/intensity/random_gamma.py - About 55 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 extract_archive has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def extract_archive(from_path, to_path=None, remove_finished=False):
        if to_path is None:
            to_path = os.path.dirname(from_path)
    
        if _is_tar(from_path):
    Severity: Minor
    Found in src/torchio/download.py - About 55 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 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in src/torchio/transforms/augmentation/intensity/random_motion.py - About 50 mins to fix

      Function plot_subject has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def plot_subject(
      Severity: Major
      Found in src/torchio/visualization.py - About 50 mins to fix

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

            def __init__(
        Severity: Minor
        Found in src/torchio/transforms/preprocessing/spatial/resample.py - About 45 mins to fix

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

          def apply_transform_to_file(
          Severity: Minor
          Found in src/torchio/utils.py - About 45 mins to fix

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

                def _fill(self) -> None:
                    assert self.sampler is not None
            
                    if self._incomplete_subject is not None:
                        subject = self._incomplete_subject
            Severity: Minor
            Found in src/torchio/data/queue.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 get_params has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def get_params(
            Severity: Minor
            Found in src/torchio/transforms/augmentation/intensity/random_motion.py - About 45 mins to fix

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

                  def __init__(
                      self,
                      target_shape: Union[int, TypeTripletInt, None] = None,
                      padding_mode: Union[str, float] = 0,
                      mask_name: Optional[str] = None,
              Severity: Minor
              Found in src/torchio/transforms/preprocessing/spatial/crop_or_pad.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 add_artifact has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def add_artifact(
                      self,
                      tensor: torch.Tensor,
                      num_ghosts: int,
                      axis: int,
              Severity: Minor
              Found in src/torchio/transforms/augmentation/intensity/random_ghosting.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 get_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_params(
                      tensor: torch.Tensor,
                      patch_size: np.ndarray,
                      num_iterations: int,
                  ) -> List[Tuple[TypeTripletInt, TypeTripletInt]]:
              Severity: Minor
              Found in src/torchio/transforms/augmentation/intensity/random_swap.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 download_and_extract_archive has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def download_and_extract_archive(
              Severity: Minor
              Found in src/torchio/download.py - About 45 mins to fix

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

                    def train(

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

                      def __init__(

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

                        def __init__(
                    Severity: Minor
                    Found in src/torchio/transforms/augmentation/intensity/random_motion.py - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language