djbrown/hbscorez

View on GitHub

Showing 30 of 113 total issues

File logic.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import logging
import operator
from typing import Any
 
 
Severity: Minor
Found in src/base/logic.py - About 2 hrs to fix

    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

    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

    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

    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

    Function scrape_league has 26 lines of code (exceeds 25 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

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

      def leg(self) -> Leg:
      other_games = self.other_games()
      if (
      not other_games
      or len(other_games) > 2
      Severity: Minor
      Found in src/games/models.py - About 55 mins to fix

      Function create_or_update_team has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def create_or_update_team(*, name, short_name, league, club, bhv_id, logger: logging.Logger = logging.getLogger()):
      Severity: Major
      Found in src/teams/models.py - About 50 mins to fix

        Function scrape_district has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def scrape_district(bhv_id, name, association: Association, options):
        if options["districts"] and bhv_id not in options["districts"]:
        LOGGER.debug("SKIPPING District (options): %s %s", bhv_id, name)
        return
         
         
        Severity: Minor
        Found in src/districts/management/commands/import_districts.py - About 45 mins to fix

        Function _create_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def _create_event(team: Team, game: Game) -> Result[Event, ErrCode]:
        if not game.opening_whistle:
        return Result.from_failure(ErrCode.MISSING_OPENING_WHISTLE)
         
        venue = "Heimspiel" if game.home_team == team else "Auswärtsspiel"
        Severity: Minor
        Found in src/teams/views.py - About 45 mins to fix

        Function rename_player has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def rename_player(team_bhv_id, old_name, new_name):
        LOGGER.info("rename Player '%s' (%s) to '%s'", old_name, team_bhv_id, new_name)
        try:
        old_player = Player.objects.get(name=old_name, team__bhv_id=team_bhv_id)
        new_player, created = Player.objects.get_or_create(name=new_name, team=old_player.team)
        Severity: Minor
        Found in src/base/management/commands/correct_data.py - About 45 mins to fix

        Function scrape_association has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def scrape_association(url: str, options):
        html = http.get_text(url)
        dom = parsing.html_dom(html)
         
        name = parsing.parse_association_name(dom)
        Severity: Minor
        Found in src/associations/management/commands/import_associations.py - About 45 mins to fix

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

        def _score(
        Severity: Minor
        Found in src/base/management/commands/correct_data.py - About 35 mins to fix

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

          def create_seasons(options):
          seasons = []
           
          for start_year in range(2004, datetime.now().year + 1):
          if options["seasons"] and start_year not in options["seasons"]:
          Severity: Minor
          Found in src/leagues/management/commands/import_leagues.py - About 35 mins to fix

          Function scrape_district_season has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          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):
          Severity: Minor
          Found in src/leagues/management/commands/import_leagues.py - About 35 mins to fix

          Function parse_goals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          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 - About 35 mins to fix

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

          def unify_player_names(*_):
          for player in Player.objects.filter(name__contains="("):
          target_name = player.name.split("(", 1)[0].strip()
          target_player, _ = Player.objects.get_or_create(name=target_name, team=player.team)
           
           
          Severity: Minor
          Found in src/base/logic.py - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language