kinkgarden/kinkgarden

View on GitHub
kinks/views.py

Summary

Maintainability
C
1 day
Test Coverage

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"]))
Severity: Minor
Found in kinks/views.py - About 3 hrs to fix

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
Severity: Minor
Found in kinks/views.py - About 3 hrs to fix

    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"]
    Severity: Minor
    Found in kinks/views.py - About 2 hrs to fix

    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"])
    Severity: Minor
    Found in kinks/views.py - About 2 hrs to fix

    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
    Severity: Major
    Found in kinks/views.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status