djbrown/hbscorez

View on GitHub

Showing 105 of 113 total issues

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

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

        light_associations = [
        {
        "bhvId": a.bhv_id,
        "name": a.name,
        "abbreviation": a.abbreviation,
        Severity: Minor
        Found in src/api/views.py and 1 other location - About 35 mins to fix
        src/api/views.py on lines 76..82

        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

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

        def teams(request, bhv_id):
        league = get_object_or_404(League, bhv_id=bhv_id)
        return render(request, "leagues/teams.j2", {"league": league})
        Severity: Minor
        Found in src/leagues/views.py and 1 other location - About 35 mins to fix
        src/associations/views.py on lines 19..21

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

        def detail(request, bhv_id):
        association = get_object_or_404(Association, bhv_id=bhv_id)
        return render(request, "associations/detail.j2", {"association": association})
        Severity: Minor
        Found in src/associations/views.py and 1 other location - About 35 mins to fix
        src/leagues/views.py on lines 34..36

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

        light_teams = [
        {
        "bhvId": team.bhv_id,
        "name": team.name,
        "shortName": team.short_name,
        Severity: Minor
        Found in src/api/views.py and 1 other location - About 35 mins to fix
        src/api/views.py on lines 9..15

        Avoid too many return statements within this function.
        Open

        return
        Severity: Major
        Found in src/players/management/commands/import_reports.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

          return
          Severity: Major
          Found in src/players/management/commands/import_reports.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

            return
            Severity: Major
            Found in src/players/management/commands/parse_report.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

              return
              Severity: Major
              Found in src/leagues/management/commands/import_leagues.py - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language