thumbor/thumbor

View on GitHub
thumbor/engines/__init__.py

Summary

Maintainability
D
1 day
Test Coverage

BaseEngine has 43 functions (exceeds 20 allowed). Consider refactoring.
Open

class BaseEngine:
    def __init__(self, context):
        self.context = context
        self.image = None
        self.extension = None
Severity: Minor
Found in thumbor/engines/__init__.py - About 5 hrs to fix

    File __init__.py has 331 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/__init__.py - About 3 hrs to fix

      Function load has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def load(self, buffer, extension):
              self.extension = extension
      
              if extension is None:
                  mime = self.get_mimetype(buffer)
      Severity: Minor
      Found in thumbor/engines/__init__.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 reorientate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def reorientate(self, override_exif=True):
              """
              Rotates the image in the buffer so that it is oriented correctly.
              If override_exif is True (default) then the metadata
              orientation is adjusted as well.
      Severity: Minor
      Found in thumbor/engines/__init__.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_mimetype has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_mimetype(cls, buffer):
              img_mime = None
      
              if buffer.startswith(b"GIF8"):
                  img_mime = "image/gif"
      Severity: Minor
      Found in thumbor/engines/__init__.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 normalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def normalize(self):
              width, height = self.size
              self.source_width = width
              self.source_height = height
      
      
      Severity: Minor
      Found in thumbor/engines/__init__.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

      There are no issues that match your filters.

      Category
      Status