Cloud-CV/EvalAI

View on GitHub

Showing 1,371 of 1,371 total issues

Avoid deeply nested control flow statements.
Open

                        if container_name in ["agent", "submission", "environment"]:
                            if container_state.terminated is not None:
                                pod_name = pods_list.items[0].metadata.name
                                try:
                                    pod_log_response = core_v1_api_instance.read_namespaced_pod_log(
Severity: Major
Found in scripts/workers/code_upload_submission_worker.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (
                            current_running_submissions_count
                            == maximum_concurrent_submissions
                        ):
                            pass
    Severity: Major
    Found in scripts/workers/submission_worker.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not (
                              isinstance(value, float) or isinstance(value, int)
                          ):
                              malformed_metrics.append((metric, type(value)))
      
      
      Severity: Major
      Found in apps/jobs/views.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if submission_serializer.is_valid():
                                submission_serializer.save()
        
                # Override submission visibility if leaderboard_public = False for a challenge phase
                if not challenge_phase.leaderboard_public:
        Severity: Major
        Found in apps/jobs/views.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if participant_email in challenge.banned_email_ids:
                                  message = "You cannot invite as you're a part of {} team and it has been banned "
                                  "from this challenge. Please contact the challenge host."
                                  response_data = {
                                      "error": message.format(participant_team.team_name)
          Severity: Major
          Found in apps/participants/views.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if metric not in leaderboard_metrics:
                                    missing_metrics.append(metric)
            
            
            Severity: Major
            Found in apps/jobs/views.py - About 45 mins to fix

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

              def download_and_extract_file(url, download_location):
                  """
                  * Function to extract download a file.
                  * `download_location` should include name of file as well.
                  """
              Severity: Minor
              Found in scripts/workers/submission_worker.py - About 45 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

              def resume_submission(request, submission_pk):
                  """
                  API endpoint to resume a submission from failed or partially evaluated state.
                  Only challenge host has access to this endpoint.
                  """
              Severity: Minor
              Found in apps/jobs/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 (
                                      isinstance(value, float) or isinstance(value, int)
                                  ):
                                      malformed_metrics.append((metric, type(value)))
                                  updated_result[metric] = value
              Severity: Major
              Found in apps/jobs/views.py - About 45 mins to fix

                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 start_ec2_instance has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def start_ec2_instance(challenge):
                                  """
                                  Start the EC2 instance associated with a challenge.
                              
                                  Args:
                              Severity: Minor
                              Found in apps/challenges/aws_utils.py - About 45 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function 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

                              Severity
                              Category
                              Status
                              Source
                              Language