Function parse_object_inv
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def parse_object_inv(stream: SphinxObjectFileReader, url: str):
result = {}
Function __init__
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
def __init__(self, team_roles: list[str]):
self.team_roles: list[str] = team_roles
self._owners: dict[int, Member] = {}
self._join_tasks: dict[tuple[Member, VoiceChannel], asyncio.Task] = {}
Function generate_color
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
def generate_color(colors: list[tuple[float, float, float]], n: int, a: float) -> tuple[float, float, float]:
guess = [random() for _ in range(3)]
last = None
for _ in range(n):
new_guess = guess.copy()
Function create_custom_command
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
def create_custom_command(custom_command: CustomCommand):
async def cmd(_, ctx: Context):
channel = ctx.bot.get_channel(custom_command.channel_id) or ctx.channel
await send_custom_command_message(ctx, custom_command, channel)
Function __init__
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def __init__(self, ctx: Context, line: str, number: int):
if not line:
raise CommandError(t.empty_option)
emoji_candidate, *text = line.lstrip().split(" ")
Function make_member_stats
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def make_member_stats(member: dict) -> tuple[int, list[str]]:
stars = ["Day Part #1 Part #2"]
completed = 0
part_avg = [[], []]
for i in range(25):
Function get_git_repo
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def get_git_repo(url: str) -> Optional[str]:
servers = [
(
r"^(https?://)?gitlab.com/([a-zA-Z0-9.\-_]+)/([a-zA-Z0-9.\-_]+)(/.*)?$",
"https://gitlab.com/api/v4/projects/{user}%2F{repo}",
Function finder
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def finder(text: str, collection: Iterable, *, key: Optional[Callable[..., str]] = None):
suggestions = []
regex = re.compile(".*?".join(map(re.escape, text.replace(" ", ""))), flags=re.IGNORECASE)
for item in collection:
to_search = key(item) if key else item
Function format_contributor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def format_contributor(self, contributor: Contributor, long: bool = False) -> Optional[str]:
discord_id, github_id = contributor
discord_mention = f"<@{discord_id}>" if discord_id else None
Function read_compressed_lines
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def read_compressed_lines(self):
buf = b""
for chunk in self.read_compressed_chunks():
buf += chunk
while True: