-
Couldn't load subscription status.
- Fork 17
Sourcery Starbot ⭐ refactored Aioxas/ax-cogs #53
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
base: master
Are you sure you want to change the base?
Conversation
| url = choice(query_find) | ||
| elif not images: | ||
| url = query_find[0] | ||
| url = choice(query_find) if images else query_find[0] |
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 AdvancedGoogle.images refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if) - Replace if statement with if expression (
assign-if-exp)
| self.servers[server.id]["status"] = not self.servers[server.id]["status"] | ||
| if "emotes" not in self.servers[server.id]: | ||
| self.servers[server.id]["emotes"] = dict() | ||
| self.servers[server.id]["emotes"] = {} |
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 Emote.set refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| self.servers[server.id] = dict({"status": False}) | ||
| if "emotes" not in self.servers[server.id]: | ||
| self.servers[server.id]["emotes"] = dict() | ||
| self.servers[server.id]["emotes"] = {} |
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 Emote.add refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| self.servers[server.id] = dict({"status": False}) | ||
| if "emotes" not in self.servers[server.id]: | ||
| self.servers[server.id]["emotes"] = dict() | ||
| self.servers[server.id]["emotes"] = {} |
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 Emote.remove refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| self.servers[server.id] = dict({"status": False}) | ||
| if "emotes" not in self.servers[server.id]: | ||
| self.servers[server.id]["emotes"] = dict() | ||
| self.servers[server.id]["emotes"] = {} |
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 Emote.edit refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| if multi < 0: | ||
| neg = True | ||
| multi = abs(multi) | ||
| if multi and type(content) is not list: | ||
| if multi < 0: | ||
| neg = True | ||
| multi = abs(multi) | ||
| content = [content.lower()] * multi | ||
| else: | ||
| if multi < 0: | ||
| neg = True | ||
| multi = abs(multi) |
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 Lootbox.add refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if)
| itemis = dict() | ||
| itemis = {} |
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 Lootbox.append refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| itemis = dict() | ||
| itemis = {} |
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 Lootbox.remove refactored with the following changes:
- Replace dict() with {} (
dict-literal)
| # create servers.json if not there | ||
| # put in default values | ||
| default = {} | ||
| if not os.path.isfile('data/lootbox/servers.json'): | ||
| print('Creating default lootbox servers.json...') | ||
| # create servers.json if not there | ||
| # put in default values | ||
| default = {} |
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 check_files refactored with the following changes:
- Move assignments closer to their usage (
move-assign)
| return True | ||
| else: | ||
| return True | ||
| return author.id == server.owner.id or author.id in bookkeeper |
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 Points.permcheck refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks) - Simplify conditional into return statement (
return-identity)
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return | ||
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return |
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 Points.add refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if) - Hoist conditional out of nested conditional (
hoist-if-from-if)
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return | ||
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return | ||
| if server.id not in self.db: | ||
| self.db[server.id] = {} | ||
| if not name: | ||
| if name: | ||
| if name.id in self.db[server.id]: | ||
| del self.db[server.id][name.id] | ||
| self.save_db() | ||
| await self.bot.say("{} has been deleted from the list.".format(name.display_name)) | ||
| else: | ||
| await self.bot.say("{} is not in the list, please make sure they have been added first to " | ||
| "the list.".format(name.display_name)) | ||
| return | ||
| 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 Points.remove refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if) - Hoist conditional out of nested conditional (
hoist-if-from-if)
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return | ||
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return |
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 Points._add refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if)
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return | ||
| if name is None: | ||
| await self.bot.say("{} was not found, please check the spelling and also make " | ||
| "sure that the member name being entered is a member in your Discord and " | ||
| "that its the same as their Discord name / nickname.".format(namea)) | ||
| return |
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 Points._remove refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if)
| return False | ||
| else: | ||
| return True | ||
| return role in [r.name.lower() for r in author.roles] |
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 The100.permcheck refactored with the following changes:
- Simplify conditional into return statement (
return-identity)
| users = [] | ||
| for z in x[y]: | ||
| users.append(z["user"]["gamertag"]) | ||
| users = [z["user"]["gamertag"] for z in x[y]] |
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 The100.games refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension)
| server = ctx.message.server | ||
| if ctx.invoked_subcommand is None or \ | ||
| isinstance(ctx.invoked_subcommand, commands.Group): | ||
| server = ctx.message.server |
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 The100.set refactored with the following changes:
- Move assignments closer to their usage (
move-assign)
| return | ||
| elif answer.content.lower().strip() == "yes": | ||
| self.db[server.id]["token"] = token | ||
| await self.bot.say("Token overwritten") | ||
| dataIO.save_json(self.json, self.db) | ||
| return | ||
| else: | ||
| await self.bot.say("Action cancelled") | ||
| return | ||
| return |
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 The100.token refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if)
| return | ||
| elif answer.content.lower().strip() == "yes": | ||
| self.db[server.id]["role"] = role | ||
| await self.bot.say("role overwritten") | ||
| dataIO.save_json(self.json, self.db) | ||
| return | ||
| else: | ||
| await self.bot.say("Action cancelled") | ||
| return | ||
| return |
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 The100.role refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: