zxc23/dcss-scoreboard

View on GitHub

Showing 35 of 211 total issues

Function score_games has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def score_games() -> set:
    """Score all unscored games."""
    start = time.time()
    scored_players = set()
    s = orm.get_session()
Severity: Minor
Found in scoreboard/scoring.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 _reraise_dberror has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _reraise_dberror(function: Callable) -> Callable:
    """Re-raise errors from decorated function as DBError or DBIntegrityError.

    Doesn't re-wrap DBError/DBIntegrityError exceptions.
    """
Severity: Minor
Found in scoreboard/model.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 is_grief has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def is_grief(s: sqlalchemy.orm.session.Session, game: orm.Game) -> bool:
    """Check if the game is a streak-breaking grief.

    This involves experimental anti-griefing heuristics.
    """
Severity: Minor
Found in scoreboard/scoring.py - About 45 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 generic_highscores_to_table has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def generic_highscores_to_table(
Severity: Minor
Found in scoreboard/webutils.py - About 45 mins to fix

    Function fastest_wins has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def fastest_wins(
    Severity: Minor
    Found in scoreboard/model.py - About 35 mins to fix

      Function write_website has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def write_website(
          players: Optional[Iterable], urlbase: str, extra_player_pages: int
      ) -> None:
          """Write all website files.
      
      
      Severity: Minor
      Found in scoreboard/write_website.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

      Function streakstotable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def streakstotable(
          streaks: Sequence[orm.Streak],
          show_player: bool = True,
          show_loss: bool = True,
          limit: Optional[int] = None,
      Severity: Minor
      Found in scoreboard/webutils.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

      Function version_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def version_url(version: str) -> str:
          """Cleans up version strings for use in morgue URLs."""
          if version[-2:] == "a0":
              return "trunk"
          if len(version) > 4:
      Severity: Minor
      Found in scoreboard/modelutils.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 False
      Severity: Major
      Found in scoreboard/log_import.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return True
        Severity: Major
        Found in scoreboard/log_import.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return False
          Severity: Major
          Found in scoreboard/log_import.py - About 30 mins to fix

            Function combo_highscores has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def combo_highscores(s: sqlalchemy.orm.session.Session) -> Sequence[Game]:
                """Return the top score for each playable combo.
            
                Not every combo may have a game in the database.
                """
            Severity: Minor
            Found in scoreboard/model.py - About 25 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 rsync_replacement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def rsync_replacement(src: str, dst: str) -> None:
                """Poor replacement for rsync on win32.
            
                Needed because shutil.copytree can't handle already existing dest dir.
                """
            Severity: Minor
            Found in scoreboard/write_website.py - About 25 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 fastest_wins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def fastest_wins(
                s: sqlalchemy.orm.session.Session,
                *,
                limit: int = const.GLOBAL_TABLE_LENGTH,
                exclude_bots: bool = True,
            Severity: Minor
            Found in scoreboard/model.py - About 25 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 setup_achievements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def setup_achievements(s: sqlalchemy.orm.session.Session) -> None:
                """Load manual achievements into the database."""
                for proto in const.ACHIEVEMENTS:
                    if (
                        not s.query(Achievement)
            Severity: Minor
            Found in scoreboard/model.py - About 25 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

            Severity
            Category
            Status
            Source
            Language