Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/kernelbot/cogs/admin_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ async def leaderboard_create_impl( # noqa: C901
forum_thread = await forum_channel.create_thread(
name=leaderboard_name,
content=self._leaderboard_opening_message(
leaderboard_name, date_value, definition.description
leaderboard_name,
date_value,
definition.description[:1500]
if len(definition.description) > 1500
Comment on lines +281 to +282
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 1500 is repeated and hardcoded. Consider defining it as a constant (e.g., MAX_DESCRIPTION_LENGTH = 1500) to improve maintainability and make the limit clear.

Suggested change
definition.description[:1500]
if len(definition.description) > 1500
definition.description[:MAX_DESCRIPTION_LENGTH]
if len(definition.description) > MAX_DESCRIPTION_LENGTH

Copilot uses AI. Check for mistakes.
else definition.description,
Comment on lines +281 to +283
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The length check len(definition.description) > 1500 is performed after already slicing the string. Consider checking the length first to avoid unnecessary string slicing: definition.description[:1500] if len(definition.description) > 1500 else definition.description

Suggested change
definition.description[:1500]
if len(definition.description) > 1500
else definition.description,
definition.description[:1500] if len(definition.description) > 1500 else definition.description,

Copilot uses AI. Check for mistakes.
),
auto_archive_duration=10080, # 7 days
)
Expand Down
Loading