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
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
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
File orm.py
has 382 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Basic data model."""
import sqlite3 # for typing
import os
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,
- Read upRead up
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
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,
- Read upRead up
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}.
- Read upRead up
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):
- Read upRead up
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":
- Read upRead up
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.';
}
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.
- Read upRead up
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
- Read upRead up
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(
Function _games
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def _games(
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:
- Read upRead up
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(
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.
"""
- Read upRead up
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")
Function count_games
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def count_games(