Skip to content

Unstable (Sourcery refactored)#13

Open
sourcery-ai[bot] wants to merge 1 commit intounstablefrom
sourcery/unstable
Open

Unstable (Sourcery refactored)#13
sourcery-ai[bot] wants to merge 1 commit intounstablefrom
sourcery/unstable

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Mar 30, 2022

Pull Request #11 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

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 unstable branch, then run:

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

Help us improve this pull request!

Comment on lines -71 to +74
image_ext = tuple([".jpg", ".png", ".jpeg"])
vid_ext = tuple([".mp4", ".mkv"])
sticker_ext = tuple([".wepb", ".tgs"])
song_ext = tuple([".mp3", ".wav", ".m4a"])
image_ext = ".jpg", ".png", ".jpeg"
vid_ext = ".mp4", ".mkv"
sticker_ext = ".wepb", ".tgs"
song_ext = ".mp3", ".wav", ".m4a"
Copy link
Author

Choose a reason for hiding this comment

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

Lines 71-74 refactored with the following changes:

Comment on lines -89 to +90
return bool(True)
return bool(True) if await is_chat_in_db(int(message.chat.id)) else bool(False)
return True
return bool(await is_chat_in_db(int(message.chat.id)))
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_harem_enabled refactored with the following changes:

Comment on lines -94 to +101
return bool(False)
return False
if not message.photo:
return bool(False)
return False
if not message.caption:
return bool(False)
return False
if "add" in message.caption.lower():
return bool(True)
return bool(False)
return True
return False
Copy link
Author

Choose a reason for hiding this comment

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

Function harem_event refactored with the following changes:

Comment on lines -48 to +50
"Stored the zip to `{}` in {} seconds.".format(downloaded_file_name, ms)
f"Stored the zip to `{downloaded_file_name}` in {ms} seconds."
)

Copy link
Author

Choose a reason for hiding this comment

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

Function test refactored with the following changes:

if not result:
return None
return result.group(1)
return result[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 find_between refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Mar 30, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.07%.

Quality metrics Before After Change
Complexity 12.00 🙂 11.98 🙂 -0.02 👍
Method Length 84.90 🙂 84.10 🙂 -0.80 👍
Working memory 12.65 😞 12.65 😞 0.00
Quality 52.75% 🙂 52.82% 🙂 0.07% 👍
Other metrics Before After Change
Lines 533 534 1
Changed files Quality Before Quality After Quality Change
any_dl.py 29.11% 😞 29.15% 😞 0.04% 👍
harem.py 80.08% ⭐ 80.45% ⭐ 0.37% 👍
unzip.py 42.14% 😞 42.00% 😞 -0.14% 👎
helper_files/dl_helpers.py 81.50% ⭐ 81.51% ⭐ 0.01% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
any_dl.py download_ 36 ⛔ 473 ⛔ 22 ⛔ 10.58% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
any_dl.py send_file 16 🙂 288 ⛔ 14 😞 32.14% 😞 Try splitting into smaller methods. Extract out complex expressions
unzip.py test 11 🙂 245 ⛔ 17 ⛔ 34.93% 😞 Try splitting into smaller methods. Extract out complex expressions
any_dl.py download_file 8 ⭐ 221 ⛔ 18 ⛔ 38.24% 😞 Try splitting into smaller methods. Extract out complex expressions
any_dl.py upload_file 9 🙂 108 🙂 13 😞 53.94% 🙂 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!

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

Comments