Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main
Open

Sourcery refactored main branch#1
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Mar 4, 2023

Branch main refactored 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 main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from amanqs March 4, 2023 12:48
@sourcery-ai
Copy link
Author

sourcery-ai bot commented Mar 4, 2023

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.05%.

Quality metrics Before After Change
Complexity 7.09 ⭐ 6.76 ⭐ -0.33 👍
Method Length 90.86 🙂 89.14 🙂 -1.72 👍
Working memory 7.59 🙂 7.85 🙂 0.26 👎
Quality 66.25% 🙂 66.20% 🙂 -0.05% 👎
Other metrics Before After Change
Lines 402 402 0
Changed files Quality Before Quality After Quality Change
helper_func.py 76.74% ⭐ 76.55% ⭐ -0.19% 👎
plugins/button.py 56.02% 🙂 55.99% 🙂 -0.03% 👎
plugins/heroku.py 56.68% 🙂 56.21% 🙂 -0.47% 👎
plugins/updater.py 69.95% 🙂 69.73% 🙂 -0.22% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
plugins/updater.py gen_chlog 2 ⭐ 156 😞 19 ⛔ 48.68% 😞 Try splitting into smaller methods. Extract out complex expressions
plugins/heroku.py varget_ 13 🙂 155 😞 10 😞 50.02% 🙂 Try splitting into smaller methods. Extract out complex expressions
plugins/button.py fsub_button 11 🙂 169 😞 10 😞 50.41% 🙂 Try splitting into smaller methods. Extract out complex expressions
plugins/heroku.py set_var 13 🙂 197 😞 8 🙂 50.53% 🙂 Try splitting into smaller methods
helper_func.py get_message_id 13 🙂 103 🙂 11 😞 54.32% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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!

Comment on lines -32 to +33
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")
Copy link
Author

Choose a reason for hiding this comment

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

Lines 32-64 refactored with the following changes:

base64_bytes = base64.urlsafe_b64encode(string_bytes)
base64_string = (base64_bytes.decode("ascii")).strip("=")
return base64_string
return (base64_bytes.decode("ascii")).strip("=")
Copy link
Author

Choose a reason for hiding this comment

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

Function encode refactored with the following changes:

string = string_bytes.decode("ascii")
return string
string_bytes = base64.urlsafe_b64decode(base64_bytes)
return string_bytes.decode("ascii")
Copy link
Author

Choose a reason for hiding this comment

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

Function decode refactored with the following changes:

Comment on lines -116 to +115
channel_id = matches.group(1)
msg_id = int(matches.group(2))
channel_id = matches[1]
msg_id = int(matches[2])
Copy link
Author

Choose a reason for hiding this comment

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

Function get_message_id refactored with the following changes:

Comment on lines -10 to +50
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"
),
Copy link
Author

Choose a reason for hiding this comment

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

Function start_button refactored with the following changes:

Comment on lines -91 to +97
if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
if FORCE_SUB_CHANNEL:
Copy link
Author

Choose a reason for hiding this comment

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

Function fsub_button refactored with the following changes:

Comment on lines -76 to +81
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}")
Copy link
Author

Choose a reason for hiding this comment

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

Function varget_ refactored with the following changes:

Comment on lines -96 to +98
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]
Copy link
Author

Choose a reason for hiding this comment

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

Function vardel_ refactored with the following changes:

msg = await message.reply_text("Checking updates...")
update_avail = updater()
if update_avail:
if update_avail := updater():
Copy link
Author

Choose a reason for hiding this comment

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

Function update_bot refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants