djbrown/hbscorez

View on GitHub

Showing 105 of 113 total issues

Cyclomatic complexity is too high in function parse_goals. (7)
Open

def parse_goals(game_row: _Element) -> tuple[int | None, int | None]:
home_goals = game_row[7].text
guest_goals = game_row[9].text
if home_goals and guest_goals:
home_goals = home_goals.strip()
Severity: Minor
Found in src/base/parsing.py by radon

Cyclomatic complexity is too high in method import_league. (7)
Open

def import_league(self, league: League):
if self.options["leagues"] and league.bhv_id not in self.options["leagues"]:
LOGGER.debug("SKIPPING League: %s (options)", league)
return
 
 

Cyclomatic complexity is too high in function scrape_sports_hall. (7)
Open

def scrape_sports_hall(game_row, processed: set[int] | None = None) -> SportsHall | None:
if processed is None:
processed = set()
 
if len(game_row[3]) != 1:
Severity: Minor
Found in src/base/logic.py by radon

Function import_game has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def import_game(self, game: Game):
if self.options["games"] and game.number not in self.options["games"]:
LOGGER.debug("SKIPPING Game (options): %s - %s", game.report_number, game)
return
 
 
Severity: Minor
Found in src/players/management/commands/import_reports.py - About 1 hr to fix

Function import_score has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def import_score(table_row, game: Game, team: Team):
row_data = [cell["text"] for cell in table_row]
 
player_number: str = row_data[0]
player_name: str = row_data[1].split("(", 1)[0].strip()
Severity: Minor
Found in src/players/management/commands/parse_report.py - About 1 hr to fix

Cyclomatic complexity is too high in function import_club. (6)
Open

def import_club(association: Association, name: str, bhv_id, options):
if options["clubs"] and bhv_id not in options["clubs"]:
LOGGER.debug("SKIPPING Club (options): %s %s", bhv_id, name)
return
 
 

Cyclomatic complexity is too high in function scrape_district_season. (6)
Open

def scrape_district_season(district: District, season: Season, options):
season_begin = date(season.start_year, 10, 1)
interval_days = 10
interval_count = 4
for interval_number in range(interval_count):

Cyclomatic complexity is too high in method create_or_update_team. (6)
Open

@staticmethod
def create_or_update_team(*, name, short_name, league, club, bhv_id, logger: logging.Logger = logging.getLogger()):
team = Team.objects.filter(bhv_id=bhv_id).first()
if team is None:
team = Team.objects.create(name=name, short_name=short_name, league=league, club=club, bhv_id=bhv_id)
Severity: Minor
Found in src/teams/models.py by radon

Function scrape_league has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def scrape_league(league_link, district, season, options): # pylint: disable=too-many-branches
abbreviation = league_link.text
bhv_id = parsing.parse_league_bhv_id(league_link)
 
if options["leagues"] and bhv_id not in options["leagues"]:
Severity: Minor
Found in src/leagues/management/commands/import_leagues.py - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def games(request, bhv_id):
league = get_object_or_404(League, bhv_id=bhv_id)
games_by_month = logic.league_games(league)
return render(request, "leagues/games.j2", {"league": league, "games_by_month": games_by_month})
Severity: Major
Found in src/leagues/views.py and 1 other location - About 1 hr to fix
src/leagues/views.py on lines 45..48

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def scorers(request, bhv_id):
league = get_object_or_404(League, bhv_id=bhv_id)
league_scorers = logic.league_scorers(league)
return render(request, "leagues/scorers.j2", {"league": league, "scorers": league_scorers})
Severity: Major
Found in src/leagues/views.py and 1 other location - About 1 hr to fix
src/leagues/views.py on lines 39..42

Similar blocks of code found in 2 locations. Consider refactoring.
Open

SCORE_SEARCH_FIELDS = (
["player_number"]
+ ["player__" + field for field in PLAYER_SEARCH_FIELDS]
+ ["game__" + field for field in GAME_SEARCH_FIELDS]
Severity: Major
Found in src/players/admin.py and 1 other location - About 1 hr to fix
src/games/admin.py on lines 8..10

Similar blocks of code found in 2 locations. Consider refactoring.
Open

["number"]
+ ["home_team__" + field for field in TEAM_SEARCH_FIELDS]
+ ["guest_team__" + field for field in TEAM_SEARCH_FIELDS]
Severity: Major
Found in src/games/admin.py and 1 other location - About 1 hr to fix
src/players/admin.py on lines 9..12

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

def parse_retirements(dom: _Element) -> list[tuple[str, datetime]]:
retirements = []
paragraphs = cast(
list[html.HtmlMixin],
dom.xpath('//table[@class="scoretable"]/following::div[following::table[@class="gametable"]]'),
Severity: Minor
Found in src/base/parsing.py - About 1 hr to fix

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Severity: Major
Found in src/districts/urls.py and 2 other locations - About 1 hr to fix
src/clubs/urls.py on lines 0..8
src/players/urls.py on lines 0..8

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Severity: Major
Found in src/players/urls.py and 2 other locations - About 1 hr to fix
src/clubs/urls.py on lines 0..8
src/districts/urls.py on lines 0..8

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Severity: Major
Found in src/clubs/urls.py and 2 other locations - About 1 hr to fix
src/districts/urls.py on lines 0..8
src/players/urls.py on lines 0..8

Function outcome_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def outcome_for(self, team) -> TeamOutcome:
if self.outcome() == GameOutcome.OPEN:
return TeamOutcome.OPEN
if self.outcome() == GameOutcome.TIE:
return TeamOutcome.TIE
Severity: Minor
Found in src/games/models.py - About 1 hr to fix

Function scrape_game has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def scrape_game(
game_row,
league: League,
whitelist: list[int] | None = None,
processed_sports_halls: set[int] | None = None,
Severity: Minor
Found in src/base/logic.py - About 1 hr to fix

Function import_leagues has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def import_leagues(options):
associations_filters = {}
if options["associations"]:
associations_filters["bhv_id__in"] = options["associations"]
associations = Association.objects.filter(**associations_filters)
Severity: Minor
Found in src/leagues/management/commands/import_leagues.py - About 1 hr to fix
Severity
Category
Status
Source
Language