slim/base/web.py
Function build_headers
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
Open
def build_headers(self):
headers = [
# TODO: bytes convert cache
[const.CONTENT_TYPE.encode('utf-8'), self.content_type.encode('utf-8')]
]
- 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 web.py
has 343 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import asyncio
import hashlib
import logging
import os
import time
Function pack_headers
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
Open
def pack_headers(self, request: 'ASGIRequest'):
def solve(val):
if isinstance(val, str):
return val
elif isinstance(val, Iterable):
- 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
Avoid deeply nested control flow statements. Open
Open
if route_info.names_varkw is not None:
for j in route_info.names_exclude:
if j in call_kwargs:
del call_kwargs[j]
Avoid deeply nested control flow statements. Open
Open
if isinstance(view, AbstractSQLView):
view.current_interface = route_info.builtin_interface
# make the method bounded
handler = route_info.handler.__get__(view)
Avoid deeply nested control flow statements. Open
Open
if not view.is_finished:
# user's validator check
await view_validate_check(view, route_info.va_query, route_info.va_post, route_info.va_headers)
ret_resp = None
Avoid deeply nested control flow statements. Open
Open
for j in call_kwargs.keys() - route_info.names_include:
del call_kwargs[j]
# build a view instance
view = await route_info.view_cls._build(app, request)