deadpyxel/digital-image-processing

View on GitHub

Showing 7 of 7 total issues

File image.py has 687 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations

import copy
from typing import Generator

Severity: Major
Found in simple_imaging/image.py - About 1 day to fix

    Image has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Image:
        def __init__(
            self,
            header: str,
            max_level: int,
    Severity: Minor
    Found in simple_imaging/image.py - About 3 hrs to fix

      Function _sliding_window has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def _sliding_window(self, size: int) -> Generator[list[list[int]], None, None]:
              """Utility method for sliding window operations
      
              This method will slide a `size x size` window in the current matrix,
              returning the current window in each step of the generator.
      Severity: Minor
      Found in simple_imaging/image.py - About 3 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 highlight_band has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def highlight_band(
              self,
              threshold: tuple[int, int],
              intensity: int,
              intensity_outside: int | None = None,
      Severity: Minor
      Found in simple_imaging/image.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 save_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def save_file(filepath: str, image: Image) -> None:
          """Writes image to disk
      
          Args:
              - filepath (str): the path to write the file too
      Severity: Minor
      Found in simple_imaging/image.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 rotate_90 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def rotate_90(self, clockwise: bool = True, inplace: bool = True) -> Image:
              """90 degree rotation
      
              Args:
                  - clockwise (bool, optional): defines the direction of rotation. Defaults to True.
      Severity: Minor
      Found in simple_imaging/image.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 binarization has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def binarization(self, threshold: int, inplace: bool = True) -> Image:
              """Binarization process
      
              Given a threshold (0 < threshold < 255), this operation wil set pixels
              below it to black and above it to white.
      Severity: Minor
      Found in simple_imaging/image.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

      Severity
      Category
      Status
      Source
      Language