Showing 30 of 113 total issues
File logic.py
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
import collections
import logging
import operator
from typing import Any
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
- 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 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()
- 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 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"]:
- 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 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"]]'),
- 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 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
- 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 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,
- 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 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)
- 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 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"]:
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
- 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 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)
- 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 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()):
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"
- 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 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
- 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 _score
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _score(
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()
- 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 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):
- 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 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"]:
- 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 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)
- 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
Avoid too many return
statements within this function. Open
return Leg.BEWTEEN