Showing 64 of 69 total issues
Function _load_results
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _load_results(self, context):
image_extension, content_type = self.define_image_type(context, None)
quality = self.context.request.quality
- 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 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"
- 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 return_contents
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def return_contents(response, url, context, req_start=None):
res = urlparse(url)
netloc = res.netloc.replace(".", "_")
code = response.code
- 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 __init__
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(
self,
debug=False,
meta=False,
trim=None,
Function fit_in_resize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def fit_in_resize(self):
source_width, source_height = self.engine.size
# invert width and height if image orientation is not the
# same as request orientation and need adaptive
- 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 handle_error
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def handle_error(self, context, handler, exception):
# create log file if not existing
if not self.logger:
if self.use_context:
obj = operator.attrgetter(self.use_context)(context)
- 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 translate_crop_coordinates
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def translate_crop_coordinates(
Function parse_url
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_url(self, url):
level = 0
while level < MAX_LEVEL:
url = self.domain_regex.sub("", url)
result = self.url_regex.match(url)
- 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 on_finish
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def on_finish(self):
super().on_finish()
self.context = getattr(self, "context", None)
if self.context is None:
- 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 get_thumbor_params
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_thumbor_params(image_url, params, config):
if params.key_file:
with open(params.key_file, "rb") as key_file:
security_key = key_file.read().strip()
else:
- 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 img_operation_worker
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def img_operation_worker(self):
if (
self.context.request.engine.extension == ".gif"
and "cover()" in self.context.request.filters
):
- 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 ensure_srgb
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ensure_srgb(img, srgb_profile=None):
"""
Ensures that an image either has no ICC profile (and so is implicitly
sRGB) or has an sRGB color profile. If the image is sRGB, it is returned
unchanged. If it has a CMYK or Gray color profile, this function will
- 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 get_detection_offset
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_detection_offset(
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function __init__
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def __init__(
self, server=None, config=None, importer=None, request_handler=None
):
self.server = server
self.config = config
- 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 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 run_optimizer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def run_optimizer(self, image_extension, buffer):
if not self.should_run(image_extension, buffer):
return buffer
if "strip_icc" in self.context.request.filters:
- 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 create_instances
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_instances(self, context, filter_params):
filter_instances = collections.defaultdict(list)
if not filter_params:
return FiltersRunner(filter_instances)
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate(context, url, normalize_url_func=_normalize_url):
url = normalize_url_func(url)
res = urlparse(url)
if not res.hostname:
- 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 compile_regex
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def compile_regex(cls, filter_data):
params = filter_data["params"]
defaults = filter_data.get("defaults", None)
regexes = []
parsers = []
- 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"