fepegar/torchio

View on GitHub

Showing 106 of 106 total issues

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

    def get_mask_from_masking_method(
Severity: Minor
Found in src/torchio/transforms/transform.py - About 35 mins to fix

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

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

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

          def apply_transform(self, subject: Subject) -> Subject:
              assert self.bounds_parameters is not None
              low = self.bounds_parameters[::2]
              for image in self.get_images(subject):
                  if isinstance(image, LabelMap) and self.padding_mode == 'mean':
      Severity: Minor
      Found in src/torchio/transforms/preprocessing/spatial/pad.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              num_ghosts: Union[int, Tuple[int, int]] = (4, 10),
              axes: Union[int, Tuple[int, ...]] = (0, 1, 2),
              intensity: Union[float, Tuple[float, float]] = (0.5, 1),
      Severity: Minor
      Found in src/torchio/transforms/augmentation/intensity/random_ghosting.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 guess_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def guess_type(string: str) -> Any:
          # Adapted from
          # https://www.reddit.com/r/learnpython/comments/4599hl/module_to_guess_type_from_a_string/czw3f5s
          string = string.replace(' ', '')
          result_type: Any
      Severity: Minor
      Found in src/torchio/utils.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 _get_subject_from_dict has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_subject_from_dict(
              data: dict,
              image_keys: Sequence[str],
              label_keys: Optional[Sequence[str]] = None,
          ) -> Subject:
      Severity: Minor
      Found in src/torchio/transforms/data_parser.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 make_gif has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def make_gif(
          tensor: torch.Tensor,
          axis: int,
          duration: float,  # of full gif
          output_path: TypePath,
      Severity: Minor
      Found in src/torchio/visualization.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, years, symmetric=False):
              self.url_dir = 'http://www.bic.mni.mcgill.ca/~vfonov/nihpd/obj1/'
              sym_string = 'sym' if symmetric else 'asym'
              if not isinstance(years, tuple) or years not in SUPPORTED_YEARS:
                  message = f'Years must be a tuple in {SUPPORTED_YEARS}'
      Severity: Minor
      Found in src/torchio/datasets/mni/pediatric.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 get_probability_map_image has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_probability_map_image(self, subject: Subject) -> Image:
              if self.probability_map_name is None:
                  for image in subject.get_images(intensity_only=False):
                      if image[TYPE] == LABEL:
                          label_map = image
      Severity: Minor
      Found in src/torchio/data/sampler/label.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self):
              self.name = 'NIFTI_ovine_05mm'
              self.url_dir = urllib.parse.urljoin(self.url_base, 'sheep/')
              self.filename = f'{self.name}.zip'
              self.url = urllib.parse.urljoin(self.url_dir, self.filename)
      Severity: Minor
      Found in src/torchio/datasets/mni/sheep.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 _write_nibabel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def _write_nibabel(
          tensor: torch.Tensor,
          affine: TypeData,
          path: TypePath,
      ) -> None:
      Severity: Minor
      Found in src/torchio/data/io.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, version=1998):
              if version not in (1998, 2008):
                  raise ValueError(f'Version must be 1998 or 2008, not "{version}"')
              self.version = version
              self.name = f'mni_colin27_{version}_nifti'
      Severity: Minor
      Found in src/torchio/datasets/mni/colin.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

      Avoid too many return statements within this function.
      Open

                  return Path(slicer_which)
      Severity: Major
      Found in src/torchio/utils.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return None  # for mypy
        Severity: Major
        Found in src/torchio/utils.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return slicer_path
          Severity: Major
          Found in src/torchio/utils.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return Path(itk_snap_which)
            Severity: Major
            Found in src/torchio/utils.py - About 30 mins to fix

              Function _glob_subjects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _glob_subjects(self, string):
                      subjects = []
                      for subject in self._subjects:
                          for image_name in subject:
                              if string in image_name:
              Severity: Minor
              Found in src/torchio/datasets/episurg.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 __getitem__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __getitem__(self, item):
                      if isinstance(item, (slice, int, tuple)):
                          try:
                              self.check_consistent_spatial_shape()
                          except RuntimeError as e:
              Severity: Minor
              Found in src/torchio/data/subject.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 inverse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def inverse(self, warn: bool = True) -> Compose:
                      """Return a composed transform with inverted order and transforms.
              
                      Args:
                          warn: Issue a warning if some transforms are not invertible.
              Severity: Minor
              Found in src/torchio/transforms/augmentation/composition.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 get_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_params(
                      self,
                      order: int,
                      coefficients_range: Tuple[float, float],
                  ) -> List[float]:
              Severity: Minor
              Found in src/torchio/transforms/augmentation/intensity/random_bias_field.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