zxc23/dcss-scoreboard

View on GitHub

Showing 35 of 211 total issues

File constants.py has 964 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Defines useful constants."""

import re
from collections import namedtuple

Severity: Major
Found in scoreboard/constants.py - About 2 days to fix

    File model.py has 678 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Defines the database models for this module."""
    
    import functools
    import datetime
    from typing import Optional, Tuple, Callable, Sequence
    Severity: Major
    Found in scoreboard/model.py - About 1 day to fix

      File webutils.py has 431 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Utility functions for website generation."""
      
      from typing import Iterable, Sequence, Optional, Callable
      import datetime  # for typing
      import uuid
      Severity: Minor
      Found in scoreboard/webutils.py - About 6 hrs to fix

        File orm.py has 382 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Basic data model."""
        
        import sqlite3  # for typing
        import os
        
        
        Severity: Minor
        Found in scoreboard/orm.py - About 5 hrs to fix

          Function _games_to_table has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          def _games_to_table(
              env: jinja2.environment.Environment,
              games: Iterable[orm.Game],
              *,
              prefix_col: Optional[Callable] = None,
          Severity: Minor
          Found in scoreboard/webutils.py - About 4 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

          File write_website.py has 332 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """Take generated score data and write out all website files."""
          
          import os
          import json
          import time
          Severity: Minor
          Found in scoreboard/write_website.py - About 4 hrs to fix

            Function _games has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

            def _games(
                s: sqlalchemy.orm.session.Session,
                *,
                player: Optional[Player] = None,
                account: Optional[Account] = None,
            Severity: Minor
            Found in scoreboard/model.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 load_logfiles has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            def load_logfiles(api_url: str) -> None:
                """Read logfiles and parse their data.
            
                Logfiles are kept in a directory with structure:
                logdir/{src}/{log or milestone file}.
            Severity: Minor
            Found in scoreboard/log_import.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 retry has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            def retry(max_tries: int, wait: int = 0) -> Callable:
                """Decorator to add basic retry functionality."""
            
                def retry_decorator(func: Callable) -> Callable:
                    def wrapper(*args, **kwargs):
            Severity: Minor
            Found in scoreboard/util.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 _morgue_prefix has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            def _morgue_prefix(src: str, version: str) -> Optional[str]:
                src = src.lower()
                if src == "cao":
                    prefix = "http://crawl.akrasiac.org/rawdata"
                elif src == "cdo":
            Severity: Minor
            Found in scoreboard/modelutils.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 inWords has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                inWords: function(distanceMillis) {
                  if (!this.settings.allowPast && ! this.settings.allowFuture) {
                      throw 'timeago allowPast and allowFuture settings can not both be set to false.';
                  }
            
            
            Severity: Minor
            Found in scoreboard/html_static/js/jquery.timeago.js - About 1 hr to fix

              Function handle_player_streak has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def handle_player_streak(s: sqlalchemy.orm.session.Session, game: orm.Game) -> None:
                  """Figure out what a game means for the player's streak.
              
                  A first win will start a streak.
                  A subsequent win (if it started after the last win) will extend the streak.
              Severity: Minor
              Found in scoreboard/scoring.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 main has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def main() -> None:
                  """Run CLI."""
                  args = read_commandline()
              
                  # XXX SUPER HACK
              Severity: Minor
              Found in loader.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 _games_to_table has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def _games_to_table(
              Severity: Major
              Found in scoreboard/webutils.py - About 1 hr to fix

                Function _games has 10 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def _games(
                Severity: Major
                Found in scoreboard/model.py - About 1 hr to fix

                  Function _get_player_records has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _get_player_records(global_records: dict, player: orm.Player) -> dict:
                      out = {}  # type: dict
                      for typ, games in global_records.items():
                          for game in games:
                              if game.player.name == player:
                  Severity: Minor
                  Found in scoreboard/write_website.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 list_games has 10 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def list_games(
                  Severity: Major
                  Found in scoreboard/model.py - About 1 hr to fix

                    Function add_game has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def add_game(s: sqlalchemy.orm.session.Session, api_game: dict) -> bool:
                        """Add a game to the database.
                    
                        Returns True if a game was found and successfully added.
                        """
                    Severity: Minor
                    Found in scoreboard/log_import.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 jinja_env has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    def jinja_env(
                        urlbase: Optional[str], s: sqlalchemy.orm.session.Session
                    ) -> jinja2.environment.Environment:
                        """Create the Jinja template environment."""
                        template_path = os.path.join(os.path.dirname(__file__), "html_templates")
                    Severity: Minor
                    Found in scoreboard/write_website.py - About 1 hr to fix

                      Function count_games has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def count_games(
                      Severity: Major
                      Found in scoreboard/model.py - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language