kinkgarden/kinkgarden

View on GitHub

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
Severity: Major
Found in kinks/tests.py - About 1 day to fix

    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

      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,
      Severity: Minor
      Found in kinks/tests.py - About 1 hr to fix

        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

          Avoid too many return statements within this function.
          Open

                  return response
          Severity: Major
          Found in base/middleware.py - About 30 mins to fix

            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"]
            Severity: Minor
            Found in kinks/templatetags/kink_column_icons.py - About 25 mins 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

            Severity
            Category
            Status
            Source
            Language