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 master branch #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

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

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

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from WinterFe July 16, 2022 01:45
Comment on lines -51 to +55
#dislikes = data["dislike_count"]
views = data["view_count"]
duration = data["duration"]
thumbnail = data["thumbnail"]
channel = data["uploader"]
channel_url = data["uploader_url"]
return Song(source, url, title, description, views, duration, thumbnail, channel, channel_url, False)
else:
if bettersearch:
url = await ytbettersearch(url)
data = await loop.run_in_executor(None, lambda: ydl.extract_info(url, download=False))
source = data["url"]
url = "https://www.youtube.com/watch?v="+data["id"]
title = data["title"]
description = data["description"]
#likes = data["like_count"]
#dislikes = data["dislike_count"]
views = data["view_count"]
duration = data["duration"]
thumbnail = data["thumbnail"]
channel = data["uploader"]
channel_url = data["uploader_url"]
return Song(source, url, title, description, views, duration, thumbnail, channel, channel_url, False)
elif search:
else:
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_video_data refactored with the following changes:

This removes the following comments ( why? ):

#dislikes = data["dislike_count"]
#likes = data["like_count"]

Comment on lines -146 to +126
else:
return None
return None
Copy link
Author

Choose a reason for hiding this comment

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

Function Music.get_player refactored with the following changes:

Comment on lines -163 to +142
if ffmpeg_error and "ffmpeg_error_betterfix" in kwargs.keys():
if ffmpeg_error and "ffmpeg_error_betterfix" in kwargs:
Copy link
Author

Choose a reason for hiding this comment

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

Function MusicPlayer.__init__ refactored with the following changes:

Comment on lines -205 to +188
elif not len(self.music.queue[self.ctx.guild.id]) > 1 and not force:
elif len(self.music.queue[self.ctx.guild.id]) <= 1 and not force:
raise EmptyQueue("Cannot skip because queue is empty")
else:
old = self.music.queue[self.ctx.guild.id][0]
old.is_looping = False if old.is_looping else False
old.is_looping = 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 MusicPlayer.skip refactored with the following changes:

Comment on lines -262 to +241
if not song.is_looping:
song.is_looping = True
else:
song.is_looping = False
song.is_looping = not song.is_looping
Copy link
Author

Choose a reason for hiding this comment

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

Function MusicPlayer.toggle_song_loop refactored with the following changes:

@@ -29,6 +29,7 @@ async def run(self, embeds, send_to=None):
msg = await msg.channel.fetch_message(msg.id)
def check(reaction, user):
return user == wait_for and reaction.message.id == msg.id and str(reaction.emoji) in self.control_emojis

Copy link
Author

Choose a reason for hiding this comment

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

Function AutoEmbedPaginator.run refactored with the following changes:

@@ -149,6 +148,7 @@ async def run(self, embeds, send_to=None):
msg = await msg.channel.fetch_message(msg.id)
def check(reaction, user):
return user == wait_for and reaction.message.id == msg.id and str(reaction.emoji) in self.control_emojis

Copy link
Author

Choose a reason for hiding this comment

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

Function CustomEmbedPaginator.run refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jul 16, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 77.84 ⛔ 69.54 ⛔ -8.30 👍
Method Length 80.46 🙂 76.78 🙂 -3.68 👍
Working memory 4.77 ⭐ 4.14 ⭐ -0.63 👍
Quality 56.43% 🙂 58.38% 🙂 1.95% 👍
Other metrics Before After Change
Lines 574 545 -29
Changed files Quality Before Quality After Quality Change
DiscordUtils/Music.py 69.16% 🙂 73.31% 🙂 4.15% 👍
DiscordUtils/Pagination.py 43.06% 😞 43.38% 😞 0.32% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
DiscordUtils/Pagination.py CustomEmbedPaginator.run 206 ⛔ 809 ⛔ 33.36% 😞 Refactor to reduce nesting. Try splitting into smaller methods
DiscordUtils/Pagination.py AutoEmbedPaginator.run 90 ⛔ 550 ⛔ 33.93% 😞 Refactor to reduce nesting. Try splitting into smaller methods
DiscordUtils/Music.py check_queue 13 🙂 181 😞 14 😞 40.95% 😞 Try splitting into smaller methods. Extract out complex expressions
DiscordUtils/Music.py get_video_data 11 🙂 205 ⛔ 11 😞 45.52% 😞 Try splitting into smaller methods. Extract out complex expressions
DiscordUtils/Music.py MusicPlayer.__init__ 6 ⭐ 124 😞 12 😞 56.32% 🙂 Try splitting into smaller methods. 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