fepegar/torchio

View on GitHub

Showing 106 of 106 total issues

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

    def get_images_dict(
        self,
        intensity_only=True,
        include: Optional[Sequence[str]] = None,
        exclude: Optional[Sequence[str]] = None,
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 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 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:
            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 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 __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 _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/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 __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 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 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 train has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def train(

                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 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 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(
                    Severity
                    Category
                    Status
                    Source
                    Language