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

    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 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

    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 _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

    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 create_or_update_team has 6 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: Minor
    Found in src/teams/models.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

      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 _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 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

        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 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

        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

        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

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

        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

        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

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

        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
        Severity: Major
        Found in src/leagues/management/commands/import_leagues.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/leagues/management/commands/import_leagues.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/leagues/management/commands/import_leagues.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language