Cloud-CV/EvalAI

View on GitHub
apps/challenges/views.py

Summary

Maintainability
F
1 mo
Test Coverage

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

import csv
import json
import logging
import os
import pytz
Severity: Major
Found in apps/challenges/views.py - About 1 wk to fix

    Function create_challenge_using_zip_file has a Cognitive Complexity of 203 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_challenge_using_zip_file(request, challenge_host_team_pk):
        """
        Creates a challenge using a zip file.
        """
        challenge_host_team = get_challenge_host_team_model(challenge_host_team_pk)
    Severity: Minor
    Found in apps/challenges/views.py - About 4 days 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 create_or_update_github_challenge has a Cognitive Complexity of 199 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_or_update_github_challenge(request, challenge_host_team_pk):
        try:
            challenge_host_team = get_challenge_host_team_model(
                challenge_host_team_pk
            )
    Severity: Minor
    Found in apps/challenges/views.py - About 4 days 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 download_all_submissions has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

    def download_all_submissions(
        request, challenge_pk, challenge_phase_pk, file_type
    ):
        """
        API endpoint to download all the submissions for a particular challenge as a csv
    Severity: Minor
    Found in apps/challenges/views.py - About 7 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 add_participant_team_to_challenge has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_participant_team_to_challenge(
        request, challenge_pk, participant_team_pk
    ):
    
        try:
    Severity: Minor
    Found in apps/challenges/views.py - About 4 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 invite_users_to_challenge has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def invite_users_to_challenge(request, challenge_pk):
    
        challenge = get_challenge_model(challenge_pk)
    
        if not challenge.is_active or not challenge.approved_by_admin:
    Severity: Minor
    Found in apps/challenges/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

    Function scale_resources_by_challenge_pk has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def scale_resources_by_challenge_pk(request, challenge_pk):
        """
        The function called by a host to update the resources used by their challenge.
    
        Calls the scale_resources method. Before calling, checks if the caller hosts the challenge and provided valid CPU
    Severity: Minor
    Found in apps/challenges/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 request_challenge_approval_by_pk has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def request_challenge_approval_by_pk(request, challenge_pk):
        """
        Checks if all challenge phases have finished submissions for the given challenge
        and send approval request for the challenge
        """
    Severity: Minor
    Found in apps/challenges/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 challenge_phase_detail has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def challenge_phase_detail(request, challenge_pk, pk):
        try:
            challenge = Challenge.objects.get(pk=challenge_pk)
        except Challenge.DoesNotExist:
            response_data = {"error": "Challenge does not exist"}
    Severity: Minor
    Found in apps/challenges/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 challenge_detail has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def challenge_detail(request, challenge_host_team_pk, challenge_pk):
        try:
            challenge_host_team = ChallengeHostTeam.objects.get(
                pk=challenge_host_team_pk
            )
    Severity: Minor
    Found in apps/challenges/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 update_allowed_email_ids has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_allowed_email_ids(request, challenge_pk, phase_pk):
        """
        API to GET/UPDATE/DELETE email ids from challenge phase allowed email ids
        Arguments:
            challenge_pk {int} -- Challenge primary key
    Severity: Minor
    Found in apps/challenges/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 deregister_participant_team_from_challenge has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def deregister_participant_team_from_challenge(request, challenge_pk):
        """
        Deregister a participant team from a challenge
        Arguments:
            challenge_pk {int} -- Challenge primary key
    Severity: Minor
    Found in apps/challenges/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 create_ec2_instance_by_challenge_pk has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_ec2_instance_by_challenge_pk(request, challenge_pk):
        """
        API to create EC2 instance for a challenge
        Arguments:
            request {HttpRequest} -- The request object
    Severity: Minor
    Found in apps/challenges/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 manage_worker has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def manage_worker(request, challenge_pk, action):
        if not request.user.is_staff:
            if not is_user_a_host_of_challenge(request.user, challenge_pk):
                response_data = {
                    "error": "Sorry, you are not authorized for access worker operations."
    Severity: Minor
    Found in apps/challenges/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 remove_participant_team_from_approved_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def remove_participant_team_from_approved_list(request, challenge_pk, participant_team_pk):
        """
        Remove participant team from approved list
        """
        try:
    Severity: Minor
    Found in apps/challenges/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 finish_annotation_file_upload has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def finish_annotation_file_upload(request, challenge_phase_pk):
        """
        API to complete multipart upload for a test annotation file
    
        Arguments:
    Severity: Minor
    Found in apps/challenges/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 manage_ec2_instance has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def manage_ec2_instance(request, challenge_pk, action):
        if not request.user.is_staff:
            response_data = {
                "error": "Sorry, you are not authorized for access EC2 operations."
            }
    Severity: Minor
    Found in apps/challenges/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 star_challenge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def star_challenge(request, challenge_pk):
        """
        API endpoint for starring and unstarring
        a challenge.
        """
    Severity: Minor
    Found in apps/challenges/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 accept_challenge_invitation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def accept_challenge_invitation(request, invitation_key):
        try:
            invitation = UserInvitation.objects.get(invitation_key=invitation_key)
        except UserInvitation.DoesNotExist:
            response_data = {
    Severity: Minor
    Found in apps/challenges/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 update_challenge_tags_and_domain has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_challenge_tags_and_domain(request, challenge_pk):
        """
        Returns or Updates challenge tags and domain
        """
        challenge = get_challenge_model(challenge_pk)
    Severity: Minor
    Found in apps/challenges/views.py - About 55 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 get_annotation_file_presigned_url has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_annotation_file_presigned_url(request, challenge_phase_pk):
        """
        API to generate a presigned url to upload a test annotation file
    
        Arguments:
    Severity: Minor
    Found in apps/challenges/views.py - About 55 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

    Avoid deeply nested control flow statements.
    Open

                        for field in request.data:
                            if field == "participant_team_members":
                                row.append(
                                    ",".join(
                                        username["username"]
    Severity: Major
    Found in apps/challenges/views.py - About 45 mins to fix

      Function get_challenges_based_on_teams has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_challenges_based_on_teams(request):
          q_params = {"approved_by_admin": True, "published": True}
          participant_team_id = request.query_params.get("participant_team", None)
          challenge_host_team_id = request.query_params.get("host_team", None)
          mode = request.query_params.get("mode", None)
      Severity: Minor
      Found in apps/challenges/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

      Avoid deeply nested control flow statements.
      Open

                              if leaderboard_ids.get(str(data["leaderboard_id"])) is None:
                                  message = (
                                      "Leaderboard with id {} doesn't exist.".format(data["leaderboard_id"])
                                  )
                                  response_data = {"error": message}
      Severity: Major
      Found in apps/challenges/views.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if attribute_type in valid_attribute_types:
                                if (
                                    attribute_type == "radio"
                                    or attribute_type == "checkbox"
                                ):
        Severity: Major
        Found in apps/challenges/views.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if serializer.is_valid():
                                      serializer.save()
                                  else:
                                      error_messages = f"challenge phase split (phase:{data['challenge_phase_id']}, leaderboard:{data['leaderboard_id']}, dataset split: {data['dataset_split_id']}):{str(serializer.errors)}"
                                      raise RuntimeError()
          Severity: Major
          Found in apps/challenges/views.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if serializer.is_valid():
                                        serializer.save()
                                    else:
                                        error_messages = f"dataset split {data['id']} :{str(serializer.errors)}"
                                        raise RuntimeError()
            Severity: Major
            Found in apps/challenges/views.py - About 45 mins to fix

              Function get_participant_teams_for_challenge has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_participant_teams_for_challenge(request, challenge_pk):
                  """
                  API to get all participant team detail
              
                  Arguments:
              Severity: Minor
              Found in apps/challenges/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

              Avoid deeply nested control flow statements.
              Open

                                  if not attribute["name"] in valid_attributes:
                                      message = "Default meta attribute: {} in phase: {} does not exist!".format(
                                          attribute["name"], data["id"]
                                      )
                                      response_data = {"error": message}
              Severity: Major
              Found in apps/challenges/views.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if challenge_test_annotation_file:
                                            serializer = ChallengePhaseCreateSerializer(
                                                data=data,
                                                context={
                                                    "challenge": challenge,
                Severity: Major
                Found in apps/challenges/views.py - About 45 mins to fix

                  Function challenge_phase_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def challenge_phase_list(request, challenge_pk):
                      try:
                          challenge = Challenge.objects.get(pk=challenge_pk)
                      except Challenge.DoesNotExist:
                          response_data = {"error": "Challenge does not exist"}
                  Severity: Minor
                  Found in apps/challenges/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

                  Avoid deeply nested control flow statements.
                  Open

                                          if serializer.is_valid():
                                              serializer.save()
                                          else:
                                              error_messages = f"leaderboard {data['id']} :{str(serializer.errors)}"
                                              raise RuntimeError()
                  Severity: Major
                  Found in apps/challenges/views.py - About 45 mins to fix

                    Function get_all_challenges has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def get_all_challenges(request, challenge_time, challenge_approved, challenge_published):
                        """
                        Returns the list of all challenges
                        """
                        # make sure that a valid url is requested.
                    Severity: Minor
                    Found in apps/challenges/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

                    Avoid deeply nested control flow statements.
                    Open

                                            if serializer.is_valid():
                                                serializer.save()
                                            else:
                                                error_messages = f"challenge phase {data['id']} :{str(serializer.errors)}"
                                                raise RuntimeError()
                    Severity: Major
                    Found in apps/challenges/views.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for email in emails:
                                                  user = User.objects.get(email=email)
                                                  host = Participant(
                                                      user=user,
                                                      status=Participant.ACCEPTED,
                      Severity: Major
                      Found in apps/challenges/views.py - About 45 mins to fix

                        Function update_challenge_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def update_challenge_attributes(request):
                            """
                            API to update attributes of the Challenge model
                            Arguments:
                                request {dict} -- Request object
                        Severity: Minor
                        Found in apps/challenges/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

                        Avoid deeply nested control flow statements.
                        Open

                                                if dataset_split_ids.get(str(data["dataset_split_id"])) is None:
                                                    message = (
                                                        "Dataset split with id {} doesn't exist.".format(data["dataset_split_id"])
                                                    )
                                                    response_data = {"error": message}
                        Severity: Major
                        Found in apps/challenges/views.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  with open(
                                                      test_annotation_file_path, "rb"
                                                  ) as test_annotation_file:
                                                      challenge_test_annotation_file = ContentFile(
                                                          test_annotation_file.read(),
                          Severity: Major
                          Found in apps/challenges/views.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if challenge_phase_ids.get(str(data["challenge_phase_id"])) is None:
                                                        message = (
                                                            "Challenge phase with phase id {} doesn't exist.".format(data["challenge_phase_id"])
                                                        )
                                                        response_data = {"error": message}
                            Severity: Major
                            Found in apps/challenges/views.py - About 45 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                  if (
                                      worker_cpu_cores == 256 and worker_memory in (512, 1024, 2048)
                                      or worker_cpu_cores == 512 and worker_memory in (1024, 2048)
                                      or worker_cpu_cores == 1024 and worker_memory == 2048
                                  ):
                              Severity: Major
                              Found in apps/challenges/views.py - About 40 mins to fix

                                Function modify_leaderboard_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def modify_leaderboard_data(request):
                                    """
                                    API to update leaderboard data
                                    Arguments:
                                        request {dict} -- Request object
                                Severity: Minor
                                Found in apps/challenges/views.py - About 35 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 validate_challenge_config has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def validate_challenge_config(request, challenge_host_team_pk):
                                    challenge_host_team = get_challenge_host_team_model(challenge_host_team_pk)
                                
                                    response_data = {}
                                
                                
                                Severity: Minor
                                Found in apps/challenges/views.py - About 35 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 delete_ec2_instance_by_challenge_pk has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def delete_ec2_instance_by_challenge_pk(request, challenge_pk):
                                    if not request.user.is_staff:
                                        response_data = {
                                            "error": "Sorry, you are not authorized for access EC2 operations."
                                        }
                                Severity: Minor
                                Found in apps/challenges/views.py - About 35 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 challenge_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def challenge_list(request, challenge_host_team_pk):
                                    try:
                                        challenge_host_team = ChallengeHostTeam.objects.get(
                                            pk=challenge_host_team_pk
                                        )
                                Severity: Minor
                                Found in apps/challenges/views.py - About 35 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 get_ec2_instance_details has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def get_ec2_instance_details(request, challenge_pk):
                                    if not request.user.is_staff:
                                        response_data = {
                                            "error": "Sorry, you are not authorized for access EC2 operations."
                                        }
                                Severity: Minor
                                Found in apps/challenges/views.py - About 35 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 add_participant_team_to_approved_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def add_participant_team_to_approved_list(request, challenge_pk, participant_team_pk):
                                    """
                                    Add participant team to approved list
                                    """
                                    try:
                                Severity: Minor
                                Found in apps/challenges/views.py - About 35 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

                                Avoid too many return statements within this function.
                                Open

                                        return Response(status=status.HTTP_204_NO_CONTENT)
                                Severity: Major
                                Found in apps/challenges/views.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                  Severity: Major
                                  Found in apps/challenges/views.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                    Severity: Major
                                    Found in apps/challenges/views.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                      Severity: Major
                                      Found in apps/challenges/views.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                            return Response(
                                        Severity: Major
                                        Found in apps/challenges/views.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                              return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                          Severity: Major
                                          Found in apps/challenges/views.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                        return Response(
                                            Severity: Major
                                            Found in apps/challenges/views.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                              Severity: Major
                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                Severity: Major
                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                  Severity: Major
                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                    Severity: Major
                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                          return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                      Severity: Major
                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                        Severity: Major
                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                              return Response(
                                                          Severity: Major
                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                        return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                            Severity: Major
                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                          return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                              Severity: Major
                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
                                                                Severity: Major
                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                          return Response(status=status.HTTP_201_CREATED)
                                                                  Severity: Major
                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                                return Response(
                                                                    Severity: Major
                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                                  return Response(response_data, status=status.HTTP_201_CREATED)
                                                                      Severity: Major
                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                                                        return Response(
                                                                        Severity: Major
                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                                          return Response(
                                                                          Severity: Major
                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                            Avoid too many return statements within this function.
                                                                            Open

                                                                                        return Response(
                                                                            Severity: Major
                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                              Avoid too many return statements within this function.
                                                                              Open

                                                                                      return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                              Severity: Major
                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                Avoid too many return statements within this function.
                                                                                Open

                                                                                        return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                                Severity: Major
                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

                                                                                          return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                  Severity: Major
                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                    Avoid too many return statements within this function.
                                                                                    Open

                                                                                                    return Response(verify_complete, status=status.HTTP_400_BAD_REQUEST)
                                                                                    Severity: Major
                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                      Avoid too many return statements within this function.
                                                                                      Open

                                                                                                      return Response(
                                                                                      Severity: Major
                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                        Avoid too many return statements within this function.
                                                                                        Open

                                                                                                return Response(response_data, status=status.HTTP_200_OK)
                                                                                        Severity: Major
                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                          Avoid too many return statements within this function.
                                                                                          Open

                                                                                                  return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                                          Severity: Major
                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                            Avoid too many return statements within this function.
                                                                                            Open

                                                                                                        return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                                            Severity: Major
                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                              Avoid too many return statements within this function.
                                                                                              Open

                                                                                                          return Response(response_data, status=status.HTTP_200_OK)
                                                                                              Severity: Major
                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                Avoid too many return statements within this function.
                                                                                                Open

                                                                                                            return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                Severity: Major
                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                  Avoid too many return statements within this function.
                                                                                                  Open

                                                                                                              return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                  Severity: Major
                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                    Avoid too many return statements within this function.
                                                                                                    Open

                                                                                                                            return Response(
                                                                                                    Severity: Major
                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                      Avoid too many return statements within this function.
                                                                                                      Open

                                                                                                              return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                      Severity: Major
                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                        Avoid too many return statements within this function.
                                                                                                        Open

                                                                                                                    return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                        Severity: Major
                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                          Avoid too many return statements within this function.
                                                                                                          Open

                                                                                                                  return Response(status=status.HTTP_204_NO_CONTENT)
                                                                                                          Severity: Major
                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                            Avoid too many return statements within this function.
                                                                                                            Open

                                                                                                                            return Response(
                                                                                                            Severity: Major
                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                              Avoid too many return statements within this function.
                                                                                                              Open

                                                                                                                          return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                              Severity: Major
                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                Avoid too many return statements within this function.
                                                                                                                Open

                                                                                                                                    return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                Severity: Major
                                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                  Avoid too many return statements within this function.
                                                                                                                  Open

                                                                                                                          return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                  Severity: Major
                                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                    Avoid too many return statements within this function.
                                                                                                                    Open

                                                                                                                            return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                    Severity: Major
                                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                      Avoid too many return statements within this function.
                                                                                                                      Open

                                                                                                                                      return Response(error_messages, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                      Severity: Major
                                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                        Avoid too many return statements within this function.
                                                                                                                        Open

                                                                                                                                        return response
                                                                                                                        Severity: Major
                                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                          Avoid too many return statements within this function.
                                                                                                                          Open

                                                                                                                                      return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                          Severity: Major
                                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                            Avoid too many return statements within this function.
                                                                                                                            Open

                                                                                                                                    return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                            Severity: Major
                                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                              Avoid too many return statements within this function.
                                                                                                                              Open

                                                                                                                                      return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                              Severity: Major
                                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                Avoid too many return statements within this function.
                                                                                                                                Open

                                                                                                                                                return Response(error_messages, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                Severity: Major
                                                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                  Avoid too many return statements within this function.
                                                                                                                                  Open

                                                                                                                                                  return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                  Severity: Major
                                                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                    Avoid too many return statements within this function.
                                                                                                                                    Open

                                                                                                                                                    return Response(
                                                                                                                                    Severity: Major
                                                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                      Avoid too many return statements within this function.
                                                                                                                                      Open

                                                                                                                                                  return Response(
                                                                                                                                      Severity: Major
                                                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                        Avoid too many return statements within this function.
                                                                                                                                        Open

                                                                                                                                                        return Response(
                                                                                                                                        Severity: Major
                                                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                          Avoid too many return statements within this function.
                                                                                                                                          Open

                                                                                                                                              return Response(response_data, status=status_code)
                                                                                                                                          Severity: Major
                                                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                            Avoid too many return statements within this function.
                                                                                                                                            Open

                                                                                                                                                                    return Response(error_messages, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                            Severity: Major
                                                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                              Avoid too many return statements within this function.
                                                                                                                                              Open

                                                                                                                                                  return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                              Severity: Major
                                                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                Avoid too many return statements within this function.
                                                                                                                                                Open

                                                                                                                                                        return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                Severity: Major
                                                                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                  Avoid too many return statements within this function.
                                                                                                                                                  Open

                                                                                                                                                      return response
                                                                                                                                                  Severity: Major
                                                                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                    Avoid too many return statements within this function.
                                                                                                                                                    Open

                                                                                                                                                                            return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                    Severity: Major
                                                                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                      Avoid too many return statements within this function.
                                                                                                                                                      Open

                                                                                                                                                              return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                      Severity: Major
                                                                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                        Avoid too many return statements within this function.
                                                                                                                                                        Open

                                                                                                                                                                        return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                        Severity: Major
                                                                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                          Avoid too many return statements within this function.
                                                                                                                                                          Open

                                                                                                                                                                                      return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                          Severity: Major
                                                                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                            Avoid too many return statements within this function.
                                                                                                                                                            Open

                                                                                                                                                                                        return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                            Severity: Major
                                                                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                              Avoid too many return statements within this function.
                                                                                                                                                              Open

                                                                                                                                                                  return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                              Severity: Major
                                                                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                Avoid too many return statements within this function.
                                                                                                                                                                Open

                                                                                                                                                                        return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                  Avoid too many return statements within this function.
                                                                                                                                                                  Open

                                                                                                                                                                          return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                  Severity: Major
                                                                                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                    Avoid too many return statements within this function.
                                                                                                                                                                    Open

                                                                                                                                                                        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                    Severity: Major
                                                                                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                      Avoid too many return statements within this function.
                                                                                                                                                                      Open

                                                                                                                                                                                  return Response({"error": error_message}, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                                      Severity: Major
                                                                                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                        Avoid too many return statements within this function.
                                                                                                                                                                        Open

                                                                                                                                                                                            return Response(
                                                                                                                                                                        Severity: Major
                                                                                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                          Avoid too many return statements within this function.
                                                                                                                                                                          Open

                                                                                                                                                                                                  return Response(error_messages, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                          Severity: Major
                                                                                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                            Avoid too many return statements within this function.
                                                                                                                                                                            Open

                                                                                                                                                                                                return Response(error_messages, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                            Severity: Major
                                                                                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                              Avoid too many return statements within this function.
                                                                                                                                                                              Open

                                                                                                                                                                                  return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                              Severity: Major
                                                                                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                Avoid too many return statements within this function.
                                                                                                                                                                                Open

                                                                                                                                                                                            return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                                Severity: Major
                                                                                                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                  Avoid too many return statements within this function.
                                                                                                                                                                                  Open

                                                                                                                                                                                              return Response(response_data, status=status.HTTP_503_SERVICE_UNAVAILABLE)
                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                    Avoid too many return statements within this function.
                                                                                                                                                                                    Open

                                                                                                                                                                                                            return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                      Avoid too many return statements within this function.
                                                                                                                                                                                      Open

                                                                                                                                                                                                          return Response(
                                                                                                                                                                                      Severity: Major
                                                                                                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                        Avoid too many return statements within this function.
                                                                                                                                                                                        Open

                                                                                                                                                                                                        return Response(
                                                                                                                                                                                        Severity: Major
                                                                                                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                          Avoid too many return statements within this function.
                                                                                                                                                                                          Open

                                                                                                                                                                                                              return Response(error_messages, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                            Avoid too many return statements within this function.
                                                                                                                                                                                            Open

                                                                                                                                                                                                    return Response({"error": error_message}, status=status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                                                            Severity: Major
                                                                                                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                              Avoid too many return statements within this function.
                                                                                                                                                                                              Open

                                                                                                                                                                                                  return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                Avoid too many return statements within this function.
                                                                                                                                                                                                Open

                                                                                                                                                                                                        return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                                                Severity: Major
                                                                                                                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                  Avoid too many return statements within this function.
                                                                                                                                                                                                  Open

                                                                                                                                                                                                      return Response(response_data, status=status_code)
                                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                    Avoid too many return statements within this function.
                                                                                                                                                                                                    Open

                                                                                                                                                                                                                                return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                      Avoid too many return statements within this function.
                                                                                                                                                                                                      Open

                                                                                                                                                                                                                          return Response(verify_complete, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                                                      Severity: Major
                                                                                                                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                        Avoid too many return statements within this function.
                                                                                                                                                                                                        Open

                                                                                                                                                                                                                return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                                                        Severity: Major
                                                                                                                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                          Avoid too many return statements within this function.
                                                                                                                                                                                                          Open

                                                                                                                                                                                                              return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                            Avoid too many return statements within this function.
                                                                                                                                                                                                            Open

                                                                                                                                                                                                                                    return Response(verify_complete, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                                                            Severity: Major
                                                                                                                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                              Avoid too many return statements within this function.
                                                                                                                                                                                                              Open

                                                                                                                                                                                                                      return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                Avoid too many return statements within this function.
                                                                                                                                                                                                                Open

                                                                                                                                                                                                                    return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                                                                Severity: Major
                                                                                                                                                                                                                Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                  Avoid too many return statements within this function.
                                                                                                                                                                                                                  Open

                                                                                                                                                                                                                                          return Response(response_data, status.HTTP_406_NOT_ACCEPTABLE)
                                                                                                                                                                                                                  Severity: Major
                                                                                                                                                                                                                  Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                    Avoid too many return statements within this function.
                                                                                                                                                                                                                    Open

                                                                                                                                                                                                                                return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                                                                    Severity: Major
                                                                                                                                                                                                                    Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                      Avoid too many return statements within this function.
                                                                                                                                                                                                                      Open

                                                                                                                                                                                                                                  return Response(
                                                                                                                                                                                                                      Severity: Major
                                                                                                                                                                                                                      Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                        Avoid too many return statements within this function.
                                                                                                                                                                                                                        Open

                                                                                                                                                                                                                                    return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                                                                        Severity: Major
                                                                                                                                                                                                                        Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                          Avoid too many return statements within this function.
                                                                                                                                                                                                                          Open

                                                                                                                                                                                                                                  return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST)
                                                                                                                                                                                                                          Severity: Major
                                                                                                                                                                                                                          Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                            Avoid too many return statements within this function.
                                                                                                                                                                                                                            Open

                                                                                                                                                                                                                                            return Response(response_data, status=status.HTTP_200_OK)
                                                                                                                                                                                                                            Severity: Major
                                                                                                                                                                                                                            Found in apps/challenges/views.py - About 30 mins to fix

                                                                                                                                                                                                                              Avoid too many return statements within this function.
                                                                                                                                                                                                                              Open

                                                                                                                                                                                                                                              return Response(
                                                                                                                                                                                                                              Severity: Major
                                                                                                                                                                                                                              Found in apps/challenges/views.py - About 30 mins to fix

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

                                                                                                                                                                                                                                def get_or_update_leaderboard(request, leaderboard_pk):
                                                                                                                                                                                                                                    """
                                                                                                                                                                                                                                    Returns or Updates a leaderboard
                                                                                                                                                                                                                                    """
                                                                                                                                                                                                                                    leaderboard = get_leaderboard_model(leaderboard_pk)
                                                                                                                                                                                                                                Severity: Minor
                                                                                                                                                                                                                                Found in apps/challenges/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 participant_team_detail_for_challenge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                                                                                Open

                                                                                                                                                                                                                                def participant_team_detail_for_challenge(request, challenge_pk):
                                                                                                                                                                                                                                    """
                                                                                                                                                                                                                                    Returns the participated team detail in the challenge
                                                                                                                                                                                                                                    Arguments:
                                                                                                                                                                                                                                        challenge_pk {int} -- Challenge primary key
                                                                                                                                                                                                                                Severity: Minor
                                                                                                                                                                                                                                Found in apps/challenges/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