Function post
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def post(self, request: HttpRequest, *args, **kwargs):
for key in ("kink-list-data", "view-password", "edit-password"):
if key not in request.POST:
raise SuspiciousOperation()
pop_edit_target(request.session, str(kwargs["pk"]))
- 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 views.py
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
from django.conf import settings
from django.core.exceptions import PermissionDenied, SuspiciousOperation
from django.db import transaction
Function get
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def get(self, request: HttpRequest, *args, **kwargs):
code = request.GET["code"]
list_id = request.GET["state"]
client_id = settings.PATREON["client_id"]
- 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 post
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def post(self, request, *args, **kwargs):
for key in ("kink-list-data", "view-password", "edit-password"):
if key not in request.POST:
raise SuspiciousOperation()
list_data = json.loads(request.POST["kink-list-data"])
- 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 tier["id"] == target_tier_id:
found_tier = True
break
break