tctree333/Bird-ID

View on GitHub
bot/cogs/race.py

Summary

Maintainability
A
3 hrs
Test Coverage

File race.py has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# race.py | commands for racing/competition
# Copyright (C) 2019-2021  EraserBird, person_v1.32, hmmm

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Severity: Minor
Found in bot/cogs/race.py - About 3 hrs to fix

    Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
    Open

        async def _send_stats(self, ctx: commands.Context, preamble):
    Severity: Critical
    Found in bot/cogs/race.py by sonar-python

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

    Refactor this function to reduce its Cognitive Complexity from 35 to the 15 allowed.
    Open

        async def start(self, ctx: commands.Context, *, args_str: str = ""):
    Severity: Critical
    Found in bot/cogs/race.py by sonar-python

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

    Error: invalid syntax (<fstring>, line 1)</fstring>
    Open

    # race.py | commands for racing/competition
    Severity: Minor
    Found in bot/cogs/race.py by radon

    We encountered an error attempting to analyze this line.

    Either merge this branch with the identical one on line "268" or change one of the implementations.
    Open

                media = "image"
    Severity: Major
    Found in bot/cogs/race.py by sonar-python

    Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

    Noncompliant Code Example

    if 0 <= a < 10:
        do_the_thing()
    elif 10 <= a < 20:
        do_the_other_thing()
    elif 20 <= a < 50:
        do_the_thing()  # Noncompliant; duplicates first condition
    else:
        do_the_rest()
    
    b = 4 if a > 12 else 4
    

    Compliant Solution

    if (0 <= a < 10) or (20 <= a < 50):
        do_the_thing()
    elif 10 <= a < 20:
        do_the_other_thing()
    else:
        do_the_rest()
    
    b = 4
    

    or

    if 0 <= a < 10:
        do_the_thing()
    elif 10 <= a < 20:
        do_the_other_thing()
    elif 20 <= a < 50:
        do_the_third_thing()
    else:
        do_the_rest()
    
    b = 8 if a > 12 else 4
    

    There are no issues that match your filters.

    Category
    Status