Conversation
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.05%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
0cb9574 to
33bf236
Compare
| HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME", None) | ||
| HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY", None) | ||
| HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME") | ||
| HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY") |
There was a problem hiding this comment.
Lines 32-64 refactored with the following changes:
- Replace
dict.get(x, None)withdict.get(x)[×3] (remove-none-from-default-get)
| base64_bytes = base64.urlsafe_b64encode(string_bytes) | ||
| base64_string = (base64_bytes.decode("ascii")).strip("=") | ||
| return base64_string | ||
| return (base64_bytes.decode("ascii")).strip("=") |
There was a problem hiding this comment.
Function encode refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| string = string_bytes.decode("ascii") | ||
| return string | ||
| string_bytes = base64.urlsafe_b64decode(base64_bytes) | ||
| return string_bytes.decode("ascii") |
There was a problem hiding this comment.
Function decode refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| channel_id = matches.group(1) | ||
| msg_id = int(matches.group(2)) | ||
| channel_id = matches[1] | ||
| msg_id = int(matches[2]) |
There was a problem hiding this comment.
Function get_message_id refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects [×2] (
use-getitem-for-re-match-groups)
| if not FORCE_SUB_CHANNEL and not FORCE_SUB_GROUP: | ||
| buttons = [ | ||
| if not FORCE_SUB_CHANNEL: | ||
| return ( | ||
| [ | ||
| InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"), | ||
| InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"), | ||
| ], | ||
| ] | ||
| return buttons | ||
| if not FORCE_SUB_CHANNEL and FORCE_SUB_GROUP: | ||
| buttons = [ | ||
| [ | ||
| InlineKeyboardButton(text="ɢʀᴏᴜᴘ", url=client.invitelink2), | ||
| ], | ||
| [ | ||
| InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"), | ||
| InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"), | ||
| ], | ||
| ] | ||
| return buttons | ||
| if FORCE_SUB_CHANNEL and not FORCE_SUB_GROUP: | ||
| buttons = [ | ||
| [ | ||
| InlineKeyboardButton(text="ɢʀᴏᴜᴘ", url=client.invitelink2), | ||
| ], | ||
| [ | ||
| InlineKeyboardButton( | ||
| text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help" | ||
| ), | ||
| InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"), | ||
| ], | ||
| ] | ||
| if FORCE_SUB_GROUP | ||
| else [ | ||
| [ | ||
| InlineKeyboardButton( | ||
| text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help" | ||
| ), | ||
| InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"), | ||
| ], | ||
| ] | ||
| ) | ||
| if not FORCE_SUB_GROUP: | ||
| return [ | ||
| [ | ||
| InlineKeyboardButton(text="ᴄʜᴀɴɴᴇʟ", url=client.invitelink), | ||
| ], | ||
| [ | ||
| InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"), | ||
| InlineKeyboardButton( | ||
| text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help" | ||
| ), | ||
| InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"), | ||
| ], | ||
| ] | ||
| return buttons | ||
| if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP: | ||
| buttons = [ | ||
| if FORCE_SUB_CHANNEL: | ||
| return [ | ||
| [ | ||
| InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"), | ||
| InlineKeyboardButton( | ||
| text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help" | ||
| ), |
There was a problem hiding this comment.
Function start_button refactored with the following changes:
- Hoist a repeated condition into a parent condition (
hoist-repeated-if-condition) - Remove redundant conditional [×3] (
remove-redundant-if) - Lift code into else after jump in control flow (
reintroduce-else) - Hoist nested repeated code outside conditional statements (
hoist-similar-statement-from-if) - Inline variable that is immediately returned [×4] (
inline-immediately-returned-variable) - Swap if/else branches of if expression to remove negation (
swap-if-expression) - Swap positions of nested conditionals (
swap-nested-ifs) - Replace if statement with if expression (
assign-if-exp)
| if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP: | ||
| if FORCE_SUB_CHANNEL: |
There was a problem hiding this comment.
Function fsub_button refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if)
| output = dotenv.get_key(path, check_var) | ||
| if not output: | ||
| await message.reply_text(f"Tidak dapat menemukan var {check_var}") | ||
| else: | ||
| if output := dotenv.get_key(path, check_var): | ||
| return await message.reply_text( | ||
| f"<b>{check_var}:</b> <code>{str(output)}</code>" | ||
| ) | ||
| else: | ||
| await message.reply_text(f"Tidak dapat menemukan var {check_var}") |
There was a problem hiding this comment.
Function varget_ refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Swap if/else branches (
swap-if-else-branches)
| if check_var in heroku_config: | ||
| await message.reply_text(f"Berhasil Menghapus var {check_var}") | ||
| del heroku_config[check_var] | ||
| else: | ||
| if check_var not in heroku_config: | ||
| return await message.reply_text(f"Tidak dapat menemukan var {check_var}") | ||
| await message.reply_text(f"Berhasil Menghapus var {check_var}") | ||
| del heroku_config[check_var] |
There was a problem hiding this comment.
Function vardel_ refactored with the following changes:
- Swap if/else branches [×3] (
swap-if-else-branches) - Remove unnecessary else after guard condition [×2] (
remove-unnecessary-else)
| msg = await message.reply_text("Checking updates...") | ||
| update_avail = updater() | ||
| if update_avail: | ||
| if update_avail := updater(): |
There was a problem hiding this comment.
Function update_bot refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!