thumbor/thumbor

View on GitHub
thumbor/engines/pil.py

Summary

Maintainability
F
3 days
Test Coverage

Function read has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
Open

    def read(  # noqa
        self, extension=None, quality=None
    ):  # noqa pylint: disable=too-many-statements,too-many-branches
        # returns image buffer in byte format.

Severity: Minor
Found in thumbor/engines/pil.py - About 1 day 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

File pil.py has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python
# -*- coding: utf-8 -*-

# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki
Severity: Minor
Found in thumbor/engines/pil.py - About 5 hrs to fix

    Engine has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Engine(BaseEngine):
        def __init__(self, context):
            super().__init__(context)
            self.subsampling = None
            self.qtables = None
    Severity: Minor
    Found in thumbor/engines/pil.py - About 3 hrs to fix

      Function create_image has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def create_image(self, buffer):
              try:
                  img = Image.open(BytesIO(buffer))
              except DECOMPRESSION_BOMB_EXCEPTIONS as error:
                  logger.warning("[PILEngine] create_image failed: %s", error)
      Severity: Minor
      Found in thumbor/engines/pil.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 image_data_as_rgb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def image_data_as_rgb(self, update_image=True):
              converted_image = self.image
      
              if converted_image.mode not in ["RGB", "RGBA"]:
                  if "A" in converted_image.mode:
      Severity: Minor
      Found in thumbor/engines/pil.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