Cloud-CV/EvalAI

View on GitHub
apps/hosts/views.py

Summary

Maintainability
F
3 days
Test Coverage

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

from django.contrib.auth.models import User

from rest_framework import permissions, status
from rest_framework.decorators import (
    api_view,
Severity: Minor
Found in apps/hosts/views.py - About 2 hrs to fix

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

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

    def challenge_host_team_detail(request, pk):
        try:
            challenge_host_team = ChallengeHostTeam.objects.get(pk=pk)
        except ChallengeHostTeam.DoesNotExist:
            response_data = {"error": "ChallengeHostTeam does not exist"}
    Severity: Minor
    Found in apps/hosts/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 challenge_host_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def challenge_host_list(request, challenge_host_team_pk):
    
        try:
            challenge_host_team = ChallengeHostTeam.objects.get(
                pk=challenge_host_team_pk
    Severity: Minor
    Found in apps/hosts/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(response_data, status=status.HTTP_202_ACCEPTED)
    Severity: Major
    Found in apps/hosts/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/hosts/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/hosts/views.py - About 30 mins to fix

          Identical blocks of code found in 6 locations. Consider refactoring.
          Open

                  if serializer.is_valid():
                      serializer.save()
                      response_data = serializer.data
                      return Response(response_data, status=status.HTTP_200_OK)
                  else:
          Severity: Major
          Found in apps/hosts/views.py and 5 other locations - About 2 hrs to fix
          apps/hosts/views.py on lines 101..107
          apps/jobs/views.py on lines 498..503
          apps/jobs/views.py on lines 2940..2945
          apps/jobs/views.py on lines 2969..2975
          apps/jobs/views.py on lines 3002..3008

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 51.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 6 locations. Consider refactoring.
          Open

                  if serializer.is_valid():
                      serializer.save()
                      response_data = serializer.data
                      return Response(response_data, status=status.HTTP_200_OK)
                  else:
          Severity: Major
          Found in apps/hosts/views.py and 5 other locations - About 2 hrs to fix
          apps/hosts/views.py on lines 200..206
          apps/jobs/views.py on lines 498..503
          apps/jobs/views.py on lines 2940..2945
          apps/jobs/views.py on lines 2969..2975
          apps/jobs/views.py on lines 3002..3008

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 51.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

              try:
                  user = User.objects.get(email=email)
              except User.DoesNotExist:
                  response_data = {
                      "error": "User does not exist with this email address!"
          Severity: Major
          Found in apps/hosts/views.py and 11 other locations - About 1 hr to fix
          apps/hosts/views.py on lines 75..79
          apps/hosts/views.py on lines 117..123
          apps/hosts/views.py on lines 165..171
          apps/hosts/views.py on lines 268..272
          apps/jobs/views.py on lines 139..143
          apps/jobs/views.py on lines 235..243
          apps/jobs/views.py on lines 438..442
          apps/jobs/views.py on lines 2595..2599
          apps/jobs/views.py on lines 2768..2772
          apps/jobs/views.py on lines 2884..2888
          apps/jobs/views.py on lines 2925..2931

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

              try:
                  challenge_host_team = ChallengeHostTeam.objects.get(
                      pk=challenge_host_team_pk
                  )
              except ChallengeHostTeam.DoesNotExist:
          Severity: Major
          Found in apps/hosts/views.py and 11 other locations - About 1 hr to fix
          apps/hosts/views.py on lines 75..79
          apps/hosts/views.py on lines 165..171
          apps/hosts/views.py on lines 268..272
          apps/hosts/views.py on lines 275..281
          apps/jobs/views.py on lines 139..143
          apps/jobs/views.py on lines 235..243
          apps/jobs/views.py on lines 438..442
          apps/jobs/views.py on lines 2595..2599
          apps/jobs/views.py on lines 2768..2772
          apps/jobs/views.py on lines 2884..2888
          apps/jobs/views.py on lines 2925..2931

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

              try:
                  challenge_host_team = ChallengeHostTeam.objects.get(pk=pk)
              except ChallengeHostTeam.DoesNotExist:
                  response_data = {"error": "ChallengeHostTeam does not exist"}
                  return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
          Severity: Major
          Found in apps/hosts/views.py and 11 other locations - About 1 hr to fix
          apps/hosts/views.py on lines 117..123
          apps/hosts/views.py on lines 165..171
          apps/hosts/views.py on lines 268..272
          apps/hosts/views.py on lines 275..281
          apps/jobs/views.py on lines 139..143
          apps/jobs/views.py on lines 235..243
          apps/jobs/views.py on lines 438..442
          apps/jobs/views.py on lines 2595..2599
          apps/jobs/views.py on lines 2768..2772
          apps/jobs/views.py on lines 2884..2888
          apps/jobs/views.py on lines 2925..2931

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

              try:
                  challenge_host_team = ChallengeHostTeam.objects.get(pk=pk)
              except ChallengeHostTeam.DoesNotExist:
                  response_data = {"error": "Host Team does not exist"}
                  return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
          Severity: Major
          Found in apps/hosts/views.py and 11 other locations - About 1 hr to fix
          apps/hosts/views.py on lines 75..79
          apps/hosts/views.py on lines 117..123
          apps/hosts/views.py on lines 165..171
          apps/hosts/views.py on lines 275..281
          apps/jobs/views.py on lines 139..143
          apps/jobs/views.py on lines 235..243
          apps/jobs/views.py on lines 438..442
          apps/jobs/views.py on lines 2595..2599
          apps/jobs/views.py on lines 2768..2772
          apps/jobs/views.py on lines 2884..2888
          apps/jobs/views.py on lines 2925..2931

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

              try:
                  challenge_host_team = ChallengeHostTeam.objects.get(
                      pk=challenge_host_team_pk
                  )
              except ChallengeHostTeam.DoesNotExist:
          Severity: Major
          Found in apps/hosts/views.py and 11 other locations - About 1 hr to fix
          apps/hosts/views.py on lines 75..79
          apps/hosts/views.py on lines 117..123
          apps/hosts/views.py on lines 268..272
          apps/hosts/views.py on lines 275..281
          apps/jobs/views.py on lines 139..143
          apps/jobs/views.py on lines 235..243
          apps/jobs/views.py on lines 438..442
          apps/jobs/views.py on lines 2595..2599
          apps/jobs/views.py on lines 2768..2772
          apps/jobs/views.py on lines 2884..2888
          apps/jobs/views.py on lines 2925..2931

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 46.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              try:
                  ChallengeHostTeam.objects.get(pk=challenge_host_team_pk)
              except ChallengeHostTeam.DoesNotExist:
                  response_data = {"error": "ChallengeHostTeam does not exist"}
                  return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
          Severity: Major
          Found in apps/hosts/views.py and 1 other location - About 1 hr to fix
          apps/jobs/views.py on lines 161..167

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 44.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              if not is_user_part_of_host_team(request.user, challenge_host_team):
                  response_data = {"error": "You are not a member of this team!"}
                  return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
          Severity: Major
          Found in apps/hosts/views.py and 2 other locations - About 55 mins to fix
          apps/jobs/views.py on lines 1503..1507
          apps/jobs/views.py on lines 2208..2212

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 37.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  if serializer.is_valid():
                      serializer.save()
                      response_data = serializer.data
                      return Response(response_data, status=status.HTTP_201_CREATED)
          Severity: Major
          Found in apps/hosts/views.py and 2 other locations - About 45 mins to fix
          apps/hosts/views.py on lines 63..66
          apps/jobs/views.py on lines 942..945

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  if serializer.is_valid():
                      serializer.save()
                      response_data = serializer.data
                      return Response(response_data, status=status.HTTP_201_CREATED)
          Severity: Major
          Found in apps/hosts/views.py and 2 other locations - About 45 mins to fix
          apps/hosts/views.py on lines 153..156
          apps/jobs/views.py on lines 942..945

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          @api_view(["GET", "POST"])
          @throttle_classes([UserRateThrottle])
          @permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
          @authentication_classes(
              (
          Severity: Major
          Found in apps/hosts/views.py and 2 other locations - About 40 mins to fix
          apps/hosts/views.py on lines 111..114
          apps/jobs/views.py on lines 904..907

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 34.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          @api_view(["GET", "POST"])
          @throttle_classes([UserRateThrottle])
          @permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
          @authentication_classes((JWTAuthentication, ExpiringTokenAuthentication))
          Severity: Major
          Found in apps/hosts/views.py and 2 other locations - About 40 mins to fix
          apps/hosts/views.py on lines 32..38
          apps/jobs/views.py on lines 904..907

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 34.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 21 locations. Consider refactoring.
          Open

          @api_view(["POST"])
          @throttle_classes([UserRateThrottle])
          @permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
          @authentication_classes((JWTAuthentication, ExpiringTokenAuthentication))
          Severity: Major
          Found in apps/hosts/views.py and 20 other locations - About 35 mins to fix
          apps/accounts/views.py on lines 41..44
          apps/accounts/views.py on lines 90..93
          apps/analytics/views.py on lines 278..281
          apps/hosts/views.py on lines 238..241
          apps/hosts/views.py on lines 262..265
          apps/jobs/views.py on lines 399..402
          apps/jobs/views.py on lines 830..833
          apps/jobs/views.py on lines 1873..1876
          apps/jobs/views.py on lines 1921..1924
          apps/jobs/views.py on lines 1992..1995
          apps/jobs/views.py on lines 2232..2235
          apps/jobs/views.py on lines 2293..2296
          apps/jobs/views.py on lines 2389..2392
          apps/jobs/views.py on lines 2439..2442
          apps/jobs/views.py on lines 2489..2492
          apps/jobs/views.py on lines 2525..2528
          apps/jobs/views.py on lines 2697..2700
          apps/jobs/views.py on lines 2820..2823
          apps/jobs/views.py on lines 2917..2920
          apps/jobs/views.py on lines 2948..2951

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 33.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 21 locations. Consider refactoring.
          Open

          @api_view(["DELETE"])
          @throttle_classes([UserRateThrottle])
          @permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
          @authentication_classes((JWTAuthentication, ExpiringTokenAuthentication))
          Severity: Major
          Found in apps/hosts/views.py and 20 other locations - About 35 mins to fix
          apps/accounts/views.py on lines 41..44
          apps/accounts/views.py on lines 90..93
          apps/analytics/views.py on lines 278..281
          apps/hosts/views.py on lines 214..217
          apps/hosts/views.py on lines 262..265
          apps/jobs/views.py on lines 399..402
          apps/jobs/views.py on lines 830..833
          apps/jobs/views.py on lines 1873..1876
          apps/jobs/views.py on lines 1921..1924
          apps/jobs/views.py on lines 1992..1995
          apps/jobs/views.py on lines 2232..2235
          apps/jobs/views.py on lines 2293..2296
          apps/jobs/views.py on lines 2389..2392
          apps/jobs/views.py on lines 2439..2442
          apps/jobs/views.py on lines 2489..2492
          apps/jobs/views.py on lines 2525..2528
          apps/jobs/views.py on lines 2697..2700
          apps/jobs/views.py on lines 2820..2823
          apps/jobs/views.py on lines 2917..2920
          apps/jobs/views.py on lines 2948..2951

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 33.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 21 locations. Consider refactoring.
          Open

          @api_view(["POST"])
          @throttle_classes([UserRateThrottle])
          @permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
          @authentication_classes((JWTAuthentication, ExpiringTokenAuthentication))
          Severity: Major
          Found in apps/hosts/views.py and 20 other locations - About 35 mins to fix
          apps/accounts/views.py on lines 41..44
          apps/accounts/views.py on lines 90..93
          apps/analytics/views.py on lines 278..281
          apps/hosts/views.py on lines 214..217
          apps/hosts/views.py on lines 238..241
          apps/jobs/views.py on lines 399..402
          apps/jobs/views.py on lines 830..833
          apps/jobs/views.py on lines 1873..1876
          apps/jobs/views.py on lines 1921..1924
          apps/jobs/views.py on lines 1992..1995
          apps/jobs/views.py on lines 2232..2235
          apps/jobs/views.py on lines 2293..2296
          apps/jobs/views.py on lines 2389..2392
          apps/jobs/views.py on lines 2439..2442
          apps/jobs/views.py on lines 2489..2492
          apps/jobs/views.py on lines 2525..2528
          apps/jobs/views.py on lines 2697..2700
          apps/jobs/views.py on lines 2820..2823
          apps/jobs/views.py on lines 2917..2920
          apps/jobs/views.py on lines 2948..2951

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 33.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status