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

def download_url(
    url: str,
    root: TypePath,
    filename: Optional[TypePath] = None,
    md5: Optional[str] = None,
Severity: Minor
Found in src/torchio/download.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 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 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 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 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_subjects has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_subjects(
                self,
                add_segmentations: bool,
                add_bounding_boxes: bool,
            ) -> List[Subject]:
        Severity: Minor
        Found in src/torchio/datasets/rsna_spine_fracture.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 create_dummy_dataset has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def create_dummy_dataset(
        Severity: Minor
        Found in src/torchio/utils.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 __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 __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

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

                  def parse_params(self, params, around, name, make_ranges=True, **kwargs):
                      params = to_tuple(params)
                      # d or (a, b)
                      if len(params) == 1 or (len(params) == 2 and make_ranges):
                          params *= 3  # (d, d, d) or (a, b, a, b, a, b)
              Severity: Minor
              Found in src/torchio/transforms/transform.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 _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 __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 train has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def train(

                  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
                    Severity
                    Category
                    Status
                    Source
                    Language