a-luna/vigorish

View on GitHub

Showing 251 of 4,109 total issues

Function scrape_status_description has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    def scrape_status_description(self):
        return (
            "Scraped all game data"
            if self.scraped_all_game_data
            else (
Severity: Minor
Found in src/vigorish/models/status_date.py - About 5 hrs 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 describe_at_bat has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def describe_at_bat(self, at_bat_id, final_event_in_at_bat, pfx_data, missing_pitch_numbers):
        if missing_pitch_numbers:
            pfx_data = None
        pitch_sequence = final_event_in_at_bat["pitch_sequence"]
        result = self.get_total_pitches_in_sequence(pitch_sequence)
Severity: Minor
Found in src/vigorish/tasks/combine_scraped_data.py - About 4 hrs 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 parse_scraped_html has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_scraped_html(self):
        parsed = 0
        for game_date in self.date_range:
            pitch_logs_for_date = self.scraped_data.get_all_brooks_pitch_logs_for_date(game_date)
            if not pitch_logs_for_date:
Severity: Minor
Found in src/vigorish/scrape/brooks_pitchfx/scrape_task.py - About 4 hrs 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 view_boxscore has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def view_boxscore(self, team_id, player_type):
        boxscore = self.get_boxscore(team_id, player_type)
        while True:
            subprocess.run(["clear"])
            result = self.select_player_prompt(player_type, boxscore)
Severity: Minor
Found in src/vigorish/cli/menu_items/view_game_data.py - About 3 hrs 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 sanitize_value_for_csv has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def sanitize_value_for_csv(val, date_format):
    if isinstance(val, str):
        val = val.replace(",", ";")
    return (
        val.strftime(date_format).strip()
Severity: Minor
Found in src/vigorish/util/dataclass_helpers.py - About 3 hrs 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 parse_scraped_html has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_scraped_html(self):
        parsed = 0
        for game_date in self.date_range:
            brooks_games_for_date = self.scraped_data.get_brooks_games_for_date(game_date)
            if not brooks_games_for_date:
Severity: Minor
Found in src/vigorish/scrape/brooks_pitch_logs/scrape_task.py - About 3 hrs 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 combine_pbp_events_with_pfx_data has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def combine_pbp_events_with_pfx_data(self):
        (self.at_bat_ids, at_bat_ids_invalid_pfx) = self.reconcile_at_bat_ids()
        all_removed_pfx = {}
        all_pfx_ab_ids = []
        self.game_events_combined_data = []
Severity: Minor
Found in src/vigorish/tasks/combine_scraped_data.py - About 3 hrs 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 patch_invalid_pfx_single_game has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def patch_invalid_pfx_single_game(self):
        result = self.patch_invalid_pfx.execute(self.game_id)
        if result.failure:
            header = f"Invalid PitchFX Data for {self.game_id}\n"
            subprocess.run(["clear"])
Severity: Minor
Found in src/vigorish/cli/menu_items/investigate_invalid_pfx.py - About 3 hrs 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 from_dict has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def from_dict(cls, bbref_game_id, bat_stats_dict):
        bbref_data = bat_stats_dict.pop("bbref_data", {})
        bbref_data["bbref_game_id"] = bbref_game_id
        bbref_data["player_id_mlb"] = bat_stats_dict["batter_id_mlb"]
        bbref_data["player_id_bbref"] = bat_stats_dict["batter_id_bbref"]
Severity: Minor
Found in src/vigorish/models/bat_stats.py - About 2 hrs 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 parse_scraped_html has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_scraped_html(self):
        parsed = 0
        self.spinner.text = self.url_tracker.parse_html_report(parsed)
        for urls_for_date in self.url_tracker.all_urls.values():
            for url_details in urls_for_date:
Severity: Minor
Found in src/vigorish/scrape/scrape_task.py - About 2 hrs 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 calc_pitch_metrics_for_at_bat has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def calc_pitch_metrics_for_at_bat(self, half_inning, at_bat, ab_num, prev_inn_pfx, prev_ab_pfx):
        pitch_samples = []
        at_bat_samples = []
        inning_samples = []
        for count, pfx in enumerate(at_bat["pitchfx"], start=1):
Severity: Minor
Found in src/vigorish/tasks/calculate_avg_pitch_times.py - About 2 hrs 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 launch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def launch(self):
        subprocess.run(["clear"])
        print_message("*** Job Details ***", fg="bright_yellow", bold=True)
        job_details = report_dict(self.job_details, title="", title_prefix="", title_suffix="")
        print_message(f"{job_details}\n", wrap=False, fg="bright_yellow")
Severity: Minor
Found in src/vigorish/cli/menu_items/job_details.py - About 2 hrs 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 _parse_starting_lineup_for_team has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def _parse_starting_lineup_for_team(page_content, team_id, is_home_team, reverse_home_away_status):
    lineup = []
    if is_home_team:
        bat_order_xpath = _HOME_LINEUP_ORDER_XPATH if not reverse_home_away_status else _AWAY_LINEUP_ORDER_XPATH
        player_link_xpath = _HOME_LINEUP_PLAYER_XPATH if not reverse_home_away_status else _AWAY_LINEUP_PLAYER_XPATH
Severity: Minor
Found in src/vigorish/scrape/bbref_boxscores/parse_html.py - About 2 hrs 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 _update_at_bat_result_stats has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def _update_at_bat_result_stats(self, final_pitch_of_ab, game_event):
        final_pitch_of_ab["is_final_pitch_of_ab"] = True
        at_bat_result = final_pitch_of_ab["des"].lower()

        if at_bat_result in AT_BAT_RESULTS_UNCLEAR:
Severity: Minor
Found in src/vigorish/tasks/combine_scraped_data.py - About 2 hrs 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 launch has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def launch(self):
        subprocess.run(["clear"])
        self.subscribe_to_events()
        result = self.select_patch_prompt()
        if result.failure:
Severity: Minor
Found in src/vigorish/cli/menu_items/investigate_invalid_pfx.py - About 2 hrs 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 retry has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def retry(
    *,
    max_attempts=2,
    delay=1,
    exceptions=(Exception,),
Severity: Minor
Found in src/vigorish/util/decorators.py - About 2 hrs 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 get_all_pbp_events_for_game has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def get_all_pbp_events_for_game(self):
        result = self.get_player_id_dict_for_game()
        if result.failure:
            return result
        self.player_id_dict = result.value
Severity: Minor
Found in src/vigorish/tasks/combine_scraped_data.py - About 2 hrs 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 parse_brooks_dashboard_page has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def parse_brooks_dashboard_page(db_session, scraped_html, game_date, url, bbref_games_for_date):
    page_content = html.fromstring(scraped_html, base_url=url)
    games_for_date = BrooksGamesForDate()
    games_for_date.game_date = game_date
    games_for_date.game_date_str = game_date.strftime(DATE_ONLY)
Severity: Minor
Found in src/vigorish/scrape/brooks_games_for_date/parse_html.py - About 2 hrs 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 launch has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def launch(self):
        while True:
            result = self.prompt_user_choose_method_to_select_game()
            if result.failure:
                break
Severity: Minor
Found in src/vigorish/cli/menus/view_game_data_menu.py - About 2 hrs 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 calc_pitch_metrics has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def calc_pitch_metrics(self, combined_data):
        all_pitch_samples = []
        all_at_bat_samples = []
        all_inning_samples = []
        prev_ab_pfx = None
Severity: Minor
Found in src/vigorish/tasks/calculate_avg_pitch_times.py - About 2 hrs 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

Severity
Category
Status
Source
Language