Cloud-CV/EvalAI

View on GitHub
apps/challenges/utils.py

Summary

Maintainability
D
1 day
Test Coverage

File utils.py has 541 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import json
import logging
import random
import string
Severity: Major
Found in apps/challenges/utils.py - About 1 day to fix

    Function add_sponsors_to_challenge has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_sponsors_to_challenge(yaml_file_data, challenge):
        if "sponsors" in yaml_file_data:
            sponsors_data = yaml_file_data['sponsors']
            sponsor_name_set = set()
    
    
    Severity: Minor
    Found in apps/challenges/utils.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 add_prizes_to_challenge has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_prizes_to_challenge(yaml_file_data, challenge):
        if "prizes" in yaml_file_data:
            prizes_data = yaml_file_data['prizes']
            rank_set = set()
            for prize in prizes_data:
    Severity: Minor
    Found in apps/challenges/utils.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 add_tags_to_challenge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_tags_to_challenge(yaml_file_data, challenge):
        if "tags" in yaml_file_data:
            tags_data = yaml_file_data["tags"]
            new_tags = set(tags_data)
            # Remove tags not present in the YAML file
    Severity: Minor
    Found in apps/challenges/utils.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

    There are no issues that match your filters.

    Category
    Status