-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
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: main
Are you sure you want to change the base?
Conversation
| for spell in spellbook: | ||
| if spell.is_awesome: | ||
| result.append(spell) | ||
| result = [spell for spell in spellbook if spell.is_awesome] |
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 refactoring_example refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension)
| if is_powerful(magic): | ||
| result = 'Magic' | ||
| else: | ||
| if not is_powerful(magic): | ||
| print("Not powerful.") | ||
| result = 'Magic' | ||
| result = 'Magic' |
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 magical_hoist refactored with the following changes:
- Hoist nested repeated code outside conditional statements (
hoist-similar-statement-from-if)
| powerful_magic = [] | ||
| for magic in magicks: | ||
| if not is_powerful(magic): | ||
| continue | ||
| powerful_magic.append(magic) | ||
| return powerful_magic | ||
| return [magic for magic in magicks if is_powerful(magic)] |
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 find_more refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Lift code into else after jump in control flow (
reintroduce-else) - Remove redundant continue statement (
remove-redundant-continue) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if magic == 'Sourcery': | ||
| return True | ||
| elif magic == 'More Sourcery': | ||
| return True | ||
| else: | ||
| return False | ||
| return magic in ['Sourcery', 'More Sourcery'] |
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 is_powerful refactored with the following changes:
- Simplify conditional into switch-like form (
switch) - Simplify boolean if expression (
boolean-if-exp-identity) - Replace if statement with if expression (
assign-if-exp) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast)
| for i in range(len(spells)): | ||
| print(spells[i]) | ||
| for spell in spells: | ||
| print(spell) |
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 print_all refactored with the following changes:
- Replace index in for loop with direct reference (
for-index-replacement)
Branch
mainrefactored 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
mainbranch, then run:Help us improve this pull request!