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.
- Read upRead up
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
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
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)
- Read upRead up
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:
- Read upRead up
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"