bot/cogs/race.py
File race.py
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed. Open
Open
async def _send_stats(self, ctx: commands.Context, preamble):
- Read upRead up
- Exclude checks
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
Open
async def start(self, ctx: commands.Context, *, args_str: str = ""):
- Read upRead up
- Exclude checks
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
Open
# race.py | commands for racing/competition
- Read upRead up
- Exclude checks
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
Open
media = "image"
- Read upRead up
- Exclude checks
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