Cloud-CV/EvalAI

View on GitHub
apps/analytics/views.py

Summary

Maintainability
D
1 day
Test Coverage

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

import csv

from datetime import timedelta

from django.http import HttpResponse
Severity: Minor
Found in apps/analytics/views.py - About 3 hrs to fix

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

        try:
            serializer = ChallengePhaseSubmissionCountSerializer(
                challenge_phase_submission_count
            )
            response_data = serializer.data
    Severity: Major
    Found in apps/analytics/views.py and 1 other location - About 2 hrs to fix
    apps/analytics/views.py on lines 267..275

    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 56.

    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:
            serializer = LastSubmissionTimestampSerializer(
                last_submission_timestamp
            )
            response_data = serializer.data
    Severity: Major
    Found in apps/analytics/views.py and 1 other location - About 2 hrs to fix
    apps/analytics/views.py on lines 169..177

    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 56.

    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

        elif duration.lower() == "monthly":
            since_date = (timezone.now() - timedelta(days=30)).replace(
    Severity: Major
    Found in apps/analytics/views.py and 1 other location - About 1 hr to fix
    apps/analytics/views.py on lines 119..120

    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 38.

    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

        elif duration.lower() == "weekly":
            since_date = (timezone.now() - timedelta(days=7)).replace(
    Severity: Major
    Found in apps/analytics/views.py and 1 other location - About 1 hr to fix
    apps/analytics/views.py on lines 124..125

    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 38.

    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 7 locations. Consider refactoring.
    Open

    @api_view(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes(
        (permissions.IsAuthenticated, HasVerifiedEmail, IsChallengeCreator)
    )
    Severity: Major
    Found in apps/analytics/views.py and 6 other locations - About 40 mins to fix
    apps/analytics/views.py on lines 52..57
    apps/analytics/views.py on lines 69..74
    apps/analytics/views.py on lines 89..94
    apps/analytics/views.py on lines 138..143
    apps/analytics/views.py on lines 215..220
    apps/analytics/views.py on lines 326..331

    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

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

    @api_view(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes(
        (permissions.IsAuthenticated, HasVerifiedEmail, IsChallengeCreator)
    )
    Severity: Major
    Found in apps/analytics/views.py and 6 other locations - About 40 mins to fix
    apps/analytics/views.py on lines 52..57
    apps/analytics/views.py on lines 89..94
    apps/analytics/views.py on lines 138..143
    apps/analytics/views.py on lines 180..185
    apps/analytics/views.py on lines 215..220
    apps/analytics/views.py on lines 326..331

    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

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

    @api_view(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes(
        (permissions.IsAuthenticated, HasVerifiedEmail, IsChallengeCreator)
    )
    Severity: Major
    Found in apps/analytics/views.py and 6 other locations - About 40 mins to fix
    apps/analytics/views.py on lines 52..57
    apps/analytics/views.py on lines 69..74
    apps/analytics/views.py on lines 89..94
    apps/analytics/views.py on lines 138..143
    apps/analytics/views.py on lines 180..185
    apps/analytics/views.py on lines 326..331

    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

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

    @api_view(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes(
        (permissions.IsAuthenticated, HasVerifiedEmail, IsChallengeCreator)
    )
    Severity: Major
    Found in apps/analytics/views.py and 6 other locations - About 40 mins to fix
    apps/analytics/views.py on lines 52..57
    apps/analytics/views.py on lines 69..74
    apps/analytics/views.py on lines 138..143
    apps/analytics/views.py on lines 180..185
    apps/analytics/views.py on lines 215..220
    apps/analytics/views.py on lines 326..331

    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

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

    @api_view(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes(
        (permissions.IsAuthenticated, HasVerifiedEmail, IsChallengeCreator)
    )
    Severity: Major
    Found in apps/analytics/views.py and 6 other locations - About 40 mins to fix
    apps/analytics/views.py on lines 52..57
    apps/analytics/views.py on lines 69..74
    apps/analytics/views.py on lines 89..94
    apps/analytics/views.py on lines 138..143
    apps/analytics/views.py on lines 180..185
    apps/analytics/views.py on lines 215..220

    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

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

    @api_view(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes(
        (permissions.IsAuthenticated, HasVerifiedEmail, IsChallengeCreator)
    )
    Severity: Major
    Found in apps/analytics/views.py and 6 other locations - About 40 mins to fix
    apps/analytics/views.py on lines 52..57
    apps/analytics/views.py on lines 69..74
    apps/analytics/views.py on lines 89..94
    apps/analytics/views.py on lines 180..185
    apps/analytics/views.py on lines 215..220
    apps/analytics/views.py on lines 326..331

    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

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

    @api_view(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes(
        (permissions.IsAuthenticated, HasVerifiedEmail, IsChallengeCreator)
    )
    Severity: Major
    Found in apps/analytics/views.py and 6 other locations - About 40 mins to fix
    apps/analytics/views.py on lines 69..74
    apps/analytics/views.py on lines 89..94
    apps/analytics/views.py on lines 138..143
    apps/analytics/views.py on lines 180..185
    apps/analytics/views.py on lines 215..220
    apps/analytics/views.py on lines 326..331

    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(["GET"])
    @throttle_classes([UserRateThrottle])
    @permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
    @authentication_classes((JWTAuthentication, ExpiringTokenAuthentication))
    Severity: Major
    Found in apps/analytics/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/hosts/views.py on lines 214..217
    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

    There are no issues that match your filters.

    Category
    Status