Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Merged
merged 1 commit into from Feb 9, 2022
Merged

Sourcery refactored main branch #1

merged 1 commit into from Feb 9, 2022

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jan 16, 2022

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!

if is_exist:
return True
else:
return False
return bool(is_exist)
Copy link
Author

Choose a reason for hiding this comment

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

Function is_user_in_db refactored with the following changes:

Comment on lines -69 to +66
if is_exist:
return True
else:
return False
return bool(is_exist)
Copy link
Author

Choose a reason for hiding this comment

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

Function is_user_in_bdb refactored with the following changes:

Comment on lines -27 to +30
''.join(["░" for i in range(20 - math.floor(percentage / 5))]),
round(percentage, 2))
''.join(["░" for _ in range(20 - math.floor(percentage / 5))]),
round(percentage, 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 progress_for_pyrogram refactored with the following changes:

Comment on lines -26 to +32

elif query.data == "helpcallback":
await query.edit_message_text(text=Messages.HELP_TXT, reply_markup=Buttons.ME_GOIN_HOME)

elif query.data == "aboutcallback":
await query.edit_message_text(text=Messages.ABOUT_TXT, reply_markup=Buttons.ME_GOIN_HOME, disable_web_page_preview=True)

Copy link
Author

Choose a reason for hiding this comment

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

Function unzipper_cb refactored with the following changes:

ext_out = ext_cmd.stdout.read()[:-1].decode("utf-8")
return ext_out
return ext_cmd.stdout.read()[:-1].decode("utf-8")
Copy link
Author

Choose a reason for hiding this comment

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

Function __run_cmds_unzipper refactored with the following changes:

Comment on lines -32 to +34
if file_path == ".zst":
os.mkdir(path)
ex = await _extract_with_zstd(path, archive_path)
return ex
else:
ex = await _extract_with_7z_helper(path, archive_path, password)
return ex
if file_path != ".zst":
return await _extract_with_7z_helper(path, archive_path, password)
os.mkdir(path)
return await _extract_with_zstd(path, archive_path)
Copy link
Author

Choose a reason for hiding this comment

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

Function extr_files refactored with the following changes:

Comment on lines -50 to -63
num = 0
i_kbd = InlineKeyboard(row_width=1)
data = []
data.append(
InlineKeyboardButton(f"Upload All ♻️", f"ext_a|{user_id}|{chat_id}")
)
data = [InlineKeyboardButton('Upload All ♻️', f"ext_a|{user_id}|{chat_id}")]
data.append(
InlineKeyboardButton("Cancel ❌", "cancel_dis")
)
for file in paths:
for num, file in enumerate(paths):
data.append(
InlineKeyboardButton(f"{num} - {os.path.basename(file)}", f"ext_f|{user_id}|{chat_id}|{num}")
)
num += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function make_keyboard refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jan 16, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 28.98 😞 29.88 😞 0.90 👎
Method Length 69.74 🙂 68.85 🙂 -0.89 👍
Working memory 15.60 ⛔ 15.95 ⛔ 0.35 👎
Quality 46.42% 😞 45.17% 😞 -1.25% 👎
Other metrics Before After Change
Lines 388 374 -14
Changed files Quality Before Quality After Quality Change
IDNCoderX/helpers/database.py 89.28% ⭐ 89.34% ⭐ 0.06% 👍
IDNCoderX/helpers/unzip_help.py 63.13% 🙂 63.13% 🙂 0.00%
IDNCoderX/modules/callbacks.py 3.05% ⛔ 3.05% ⛔ 0.00%
IDNCoderX/modules/ext_script/ext_helper.py 81.58% ⭐ 82.66% ⭐ 1.08% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
IDNCoderX/modules/callbacks.py unzipper_cb 64 ⛔ 911 ⛔ 26 ⛔ 3.05% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
IDNCoderX/helpers/unzip_help.py progress_for_pyrogram 6 ⭐ 154 😞 16 ⛔ 47.57% 😞 Try splitting into smaller methods. Extract out complex expressions
IDNCoderX/helpers/unzip_help.py TimeFormatter 5 ⭐ 89 🙂 13 😞 60.38% 🙂 Extract out complex expressions
IDNCoderX/helpers/database.py check_user 2 ⭐ 76 🙂 12 😞 66.82% 🙂 Extract out complex expressions
IDNCoderX/helpers/unzip_help.py check_logs 7 ⭐ 56 ⭐ 10 😞 68.63% 🙂 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!

@UserLazy UserLazy merged commit ad1ac90 into main Feb 9, 2022
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.

None yet

1 participant