ejplatform/ej-server

View on GitHub
src/ej_conversations/views.py

Summary

Maintainability
B
6 hrs
Test Coverage

File views.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from logging import getLogger

from django.db import transaction
from django.db.models import F
from django.http import HttpResponse, HttpResponseServerError, JsonResponse
Severity: Minor
Found in src/ej_conversations/views.py - About 2 hrs to fix

    Function moderate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def moderate(request, conversation_id, slug, board_slug):
        conversation = Conversation.objects.get(id=conversation_id)
    
        if request.method == "POST":
            post_parameters = dict(request.POST)
    Severity: Minor
    Found in src/ej_conversations/views.py - About 1 hr 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 edit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def edit(request, conversation_id, slug, board_slug, **kwargs):
        conversation = Conversation.objects.get(id=conversation_id)
        board = Board.objects.get(slug=board_slug)
        form = forms.ConversationForm(request=request, instance=conversation)
        can_publish = request.user.has_perm("ej_conversations.can_publish_promoted")
    Severity: Minor
    Found in src/ej_conversations/views.py - About 45 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

    Function edit has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def edit(request, conversation_id, slug, board_slug, **kwargs):
    Severity: Minor
    Found in src/ej_conversations/views.py - About 35 mins to fix

      Function detail has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def detail(request, conversation_id, slug, board_slug, check=check_promoted):
      Severity: Minor
      Found in src/ej_conversations/views.py - About 35 mins to fix

        Function new_comment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def new_comment(request, conversation_id, slug, board_slug):
            conversation = Conversation.objects.get(id=conversation_id)
            fields = dict(request.POST)
            if "comment" in fields:
                comments = dict(request.POST)["comment"]
        Severity: Minor
        Found in src/ej_conversations/views.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

        Function detail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def detail(request, conversation_id, slug, board_slug, check=check_promoted):
            conversation = Conversation.objects.get(id=conversation_id)
            check(conversation, request)
            user = request.user
            form = forms.CommentForm(conversation=conversation)
        Severity: Minor
        Found in src/ej_conversations/views.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

        There are no issues that match your filters.

        Category
        Status