Showing 9 of 9 total issues
File tests.py
has 520 lines of code (exceeds 250 allowed). Consider refactoring. Open
import typing
import json
from django.test import TestCase
from django.urls import reverse
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
Function test_edit_happy_path_works
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_edit_happy_path_works(self):
edit_password = "insecure"
list_args = dict(edit_password=make_password(edit_password))
(
custom_description,
Avoid deeply nested control flow statements. Open
if tier["id"] == target_tier_id:
found_tier = True
break
break
Avoid too many return
statements within this function. Open
return response
Function icon_svg
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def icon_svg():
from xml.dom import minidom
impl = minidom.getDOMImplementation()
icons = ["heart", "check", "tilde", "no"]
- 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"