Showing 118 of 118 total issues
Avoid deeply nested control flow statements. Open
if i.builtin_interface == BuiltinInterface.LIST:
page_info = deepcopy(paginate_schema)
page_info["properties"]["items"] = {
"type": "array",
"description": "数据项",
Function current_user
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def current_user(self) -> BaseUser:
if not self.can_get_user:
raise NoUserViewMixinException("Current View should inherited from `BaseUserViewMixin` or it's subclasses")
if not self._current_user:
func = getattr(self, 'get_current_user', 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 __new__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __new__(cls, val):
if isinstance(val, (memoryview, bytes)):
return val
# FIX: 其实这可能有点问题,因为None是一个合法的值
if val 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
Avoid deeply nested control flow statements. 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
if i.builtin_interface == BuiltinInterface.SET:
if view_info['sql_cant_write']:
continue
add_bulk_header()
add_returning_header()
Avoid deeply nested control flow statements. 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
if sql_query:
parameters.extend(view_info['sql_query_parameters'])
Avoid deeply nested control flow statements. 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
if isinstance(items, (List, Tuple)):
for i in items:
write_values.append(do_validate(va_write_value, i, InvalidPostData))
else:
raise InvalidPostData("`items` from post data should be list")
Function append_validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def append_validate(va_query: Type[Model] = None, va_post: Type[Model] = None, va_write_value: Type[Model] = None,
va_headers: Type[Model] = None):
"""
:param va_query:
:param va_post:
- 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
if i.builtin_interface == BuiltinInterface.DELETE:
if view_info['sql_cant_delete']:
continue
add_bulk_header()
request_body_schema = {
Function _interface_solve
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _interface_solve(self, beacon_info: RouteInterfaceInfo, method, parameters, request_body_schema):
if beacon_info.va_query:
for k, v in beacon_info.va_query._fields.items():
parameters.append(self._schematics_field_to_parameter(k, v))
- 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 teardown_user_token
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def teardown_user_token(self: Union['BaseUserViewMixin', 'BaseView'], token=sentinel):
""" signout, invalidate the token here """
u = self.current_user
if u:
if token 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
Avoid deeply nested control flow statements. Open
if not i.startswith('_') and i.endswith('.py'):
modname = os.path.relpath(fn, base_path)[:-3].replace(os.path.sep, '.')
# modpath = os.path.abspath(fn)
# logger.debug('Auto load module: %s from %r' % (modname, modpath))
Avoid deeply nested control flow statements. Open
if i.builtin_interface == BuiltinInterface.LIST:
parameters.extend([
{
"name": "page",
"in": "path",
Function interface
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def interface(self, method, url=None, *, summary=None, va_query=None, va_post=None, va_headers=None,
va_resp=ResponseDataModel, deprecated=False):
"""
Register interface
:param method:
- 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 do_request
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def do_request(self, method, rel_path, params=None, post_data=None, role=None, access_token=None):
Avoid deeply nested control flow statements. Open
if i.builtin_interface == BuiltinInterface.NEW:
if view_info['sql_cant_create']:
continue
add_returning_header()
request_body_schema = {
Function __init__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, *, cookies_secret: bytes = b'secret code', log_level=logging.INFO, session_cls=CookieSession,
mountpoint: str = '/api', doc_enable=True, doc_info=ApplicationDocInfo(),
permission: Optional['Permissions'] = None, client_max_size=100 * 1024 * 1024,
cors_options: Optional[CORSOptions] = 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
Avoid deeply nested control flow statements. Open
if f:
doc = f.__doc__
if doc: doc = doc.strip()
if doc: break