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
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)
- 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 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")
- 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 edit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def edit(request, conversation_id, slug, board_slug, **kwargs):
Function detail
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def detail(request, conversation_id, slug, board_slug, check=check_promoted):
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"]
- 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 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)
- 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"