fepegar/torchio

View on GitHub
src/torchio/visualization.py

Summary

Maintainability
C
1 day
Test Coverage

Function plot_volume has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def plot_volume(
    image: Image,
    radiological=True,
    channel=-1,  # default to foreground for binary maps
    axes=None,
Severity: Minor
Found in src/torchio/visualization.py - About 2 hrs 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 plot_subject has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def plot_subject(
    subject: Subject,
    cmap_dict=None,
    show=True,
    output_path=None,
Severity: Minor
Found in src/torchio/visualization.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 plot_volume has 13 arguments (exceeds 4 allowed). Consider refactoring.
Open

def plot_volume(
Severity: Major
Found in src/torchio/visualization.py - About 1 hr to fix

    Function plot_volume has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def plot_volume(
        image: Image,
        radiological=True,
        channel=-1,  # default to foreground for binary maps
        axes=None,
    Severity: Minor
    Found in src/torchio/visualization.py - About 1 hr to fix

      Function make_gif has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def make_gif(
      Severity: Major
      Found in src/torchio/visualization.py - About 1 hr 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 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 color_labels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def color_labels(arrays, cmap_dict):
              results = []
              for array in arrays:
                  si, sj = array.shape
                  rgb = np.zeros((si, sj, 3), dtype=np.uint8)
          Severity: Minor
          Found in src/torchio/visualization.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

          There are no issues that match your filters.

          Category
          Status