Showing 5 of 5 total issues
File views.py
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
import abc
import inspect
import json
import math
import os
Function _parse_query_args
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _parse_query_args(self, request: sanic.request.Request) -> tuple[dict[str, Any], int, int]:
query_args = {}
for q_key, value in request.query_args:
key = f"{self.search_field}__startswith" if q_key == "q" else q_key
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, data, model_klass: type[Document] | None = None, current_obj: Document | None = None):
model_klass = model_klass or self.model
model_data = (current_obj.dict() if current_obj else {}) | data
try:
- 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 _parse_body
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _parse_body(self, request: sanic.request.Request) -> tuple[dict[str, Any], dict[str, sanic.request.File]]:
if "form" in request.content_type:
data = {}
for key, form_value in dict(request.form).items():
value = [json.loads(item) for item in form_value]
- 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_options
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_options(klass):
payload = {}
for field_name, field_info in klass.__fields__.items():
if inspect.isclass(field_info.type_) and issubclass(field_info.type_, EmbeddedDocument):
field_type = "struct"
- 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"