-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
#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: |
There was a problem hiding this comment.
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:
- Hoist repeated code outside conditional statement [×16] (
hoist-statement-from-if
) - Remove redundant conditional (
remove-redundant-if
)
This removes the following comments ( why? ):
#dislikes = data["dislike_count"]
#likes = data["like_count"]
else: | ||
return None | ||
return None |
There was a problem hiding this comment.
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:
- If else clause is always executed move code to same level as loop (
useless-else-on-loop
)
if ffmpeg_error and "ffmpeg_error_betterfix" in kwargs.keys(): | ||
if ffmpeg_error and "ffmpeg_error_betterfix" in kwargs: |
There was a problem hiding this comment.
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:
- Remove unnecessary call to keys() (
remove-dict-keys
)
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 |
There was a problem hiding this comment.
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:
- Simplify logical expression using De Morgan identities (
de-morgan
) - Remove an unnecessary condition used during variable assignment (
remove-redundant-condition
)
if not song.is_looping: | ||
song.is_looping = True | ||
else: | ||
song.is_looping = False | ||
song.is_looping = not song.is_looping |
There was a problem hiding this comment.
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:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
) - Replace if statement with if expression (
assign-if-exp
)
@@ -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 | |||
|
There was a problem hiding this comment.
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:
- Remove unreachable code [×2] (
remove-unreachable-code
) - Replace comparison with min/max call (
min-max-identity
)
@@ -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 | |||
|
There was a problem hiding this comment.
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:
- Remove unreachable code [×3] (
remove-unreachable-code
) - Replace comparison with min/max call [×6] (
min-max-identity
) - Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 1.95%.
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! |
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:Help us improve this pull request!