File views.py
has 474 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.contrib.auth.models import User
from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema
from rest_framework import permissions, status
Function invite_participant_to_team
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def invite_participant_to_team(request, pk):
try:
participant_team = ParticipantTeam.objects.get(pk=pk)
except ParticipantTeam.DoesNotExist:
response_data = {"error": "Participant Team does not exist"}
- 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 participant_team_detail
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def participant_team_detail(request, pk):
try:
participant_team = ParticipantTeam.objects.get(pk=pk)
except ParticipantTeam.DoesNotExist:
- 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 remove_participant_team_from_challenge
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def remove_participant_team_from_challenge(
request, challenge_pk, participant_team_pk
):
"""
API to remove the participant team from a challenge
- 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
Avoid deeply nested control flow statements. Open
for domain in challenge.allowed_email_domains:
domains = "{}{}{}".format(domains, "/", domain)
domains = domains[1:]
Avoid deeply nested control flow statements. Open
if participant_email in challenge.banned_email_ids:
message = "You cannot invite as you're a part of {} team and it has been banned "
"from this challenge. Please contact the challenge host."
response_data = {
"error": message.format(participant_team.team_name)
Function delete_participant_from_team
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def delete_participant_from_team(request, participant_team_pk, participant_pk):
"""
Deletes a participant from a Participant Team
"""
try:
- 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 get_teams_and_corresponding_challenges_for_a_participant
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_teams_and_corresponding_challenges_for_a_participant(
request, challenge_pk
):
"""
Returns list of teams and corresponding challenges for a participant
- 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
Avoid too many return
statements within this function. Open
return Response(
Avoid too many return
statements within this function. Open
return Response(response_data, status=status.HTTP_200_OK)
Avoid too many return
statements within this function. Open
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
Avoid too many return
statements within this function. Open
return Response(
Avoid too many return
statements within this function. Open
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Avoid too many return
statements within this function. Open
return Response(
Avoid too many return
statements within this function. Open
return Response(response_data, status=status.HTTP_401_UNAUTHORIZED)
Avoid too many return
statements within this function. Open
return Response(errors, status=status.HTTP_400_BAD_REQUEST)
Avoid too many return
statements within this function. Open
return Response(
Avoid too many return
statements within this function. Open
return Response(response_data, status=status.HTTP_202_ACCEPTED)
Function remove_self_from_participant_team
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_self_from_participant_team(request, participant_team_pk):
"""
A user can remove himself from the participant team.
"""
try:
- 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"