ocadotechnology/rapid-router

View on GitHub
game/views/scoreboard.py

Summary

Maintainability
D
2 days
Test Coverage

Function student_row has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

def student_row(levels_sorted, student, best_attempts):
    threshold = 0.5

    num_all = num_finished = num_attempted = num_started = 0
    total_score = 0
Severity: Minor
Found in game/views/scoreboard.py - About 1 day 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

File scoreboard.py has 397 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

from __future__ import absolute_import
from __future__ import division

from builtins import map
from builtins import next
Severity: Minor
Found in game/views/scoreboard.py - About 5 hrs to fix

    Function scoreboard has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def scoreboard(request):
        """
        Renders a page with students' scores. A teacher can see the visible classes in
        their school. Student's view is restricted to their class if their teacher enabled
        the scoreboard for said class.
    Severity: Minor
    Found in game/views/scoreboard.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 _check_attempts has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _check_attempts(best_attempts):
        threshold = 0.5
    
        # episode ids with low attempts (below 50%)
        low_episode_ids = set()
    Severity: Minor
    Found in game/views/scoreboard.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 scoreboard_view has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def scoreboard_view(
    Severity: Major
    Found in game/views/scoreboard.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          if not attempt.level.disable_algorithm_score:
                              max_score += 10
                          if int(attempt.level.name) < 13:
      Severity: Major
      Found in game/views/scoreboard.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if int(attempt.level.name) < 13:
                                max_score = 20
        
        
        Severity: Major
        Found in game/views/scoreboard.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if not attempt.level.disable_route_score:
                                  max_score += 10
                              if not attempt.level.disable_algorithm_score:
          Severity: Major
          Found in game/views/scoreboard.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if attempt.score / max_score >= threshold:
                                    num_finished += 1
                                else:
                                    num_attempted += 1
                            else:
            Severity: Major
            Found in game/views/scoreboard.py - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                      return scoreboard_view(
              Severity: Major
              Found in game/views/scoreboard.py - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status