Open
Conversation
| for spell in spellbook: | ||
| if spell.is_awesome: | ||
| result.append(spell) | ||
| result = [spell for spell in spellbook if spell.is_awesome] |
Author
There was a problem hiding this comment.
Function refactoring_example refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension)
Comment on lines
-30
to
+29
| if is_powerful(magic): | ||
| result = 'Magic' | ||
| else: | ||
| if not is_powerful(magic): | ||
| print("Not powerful.") | ||
| result = 'Magic' | ||
| result = 'Magic' |
Author
There was a problem hiding this comment.
Function magical_hoist refactored with the following changes:
- Hoist nested repeated code outside conditional statements (
hoist-similar-statement-from-if)
Comment on lines
-75
to
+70
| 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)] |
Author
There was a problem hiding this comment.
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)
Comment on lines
-84
to
+74
| if magic == 'Sourcery': | ||
| return True | ||
| elif magic == 'More Sourcery': | ||
| return True | ||
| else: | ||
| return False | ||
| return magic in ['Sourcery', 'More Sourcery'] |
Author
There was a problem hiding this comment.
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)
Comment on lines
-93
to
+79
| for i in range(len(spells)): | ||
| print(spells[i]) | ||
| for spell in spells: | ||
| print(spell) |
Author
There was a problem hiding this comment.
Function print_all refactored with the following changes:
- Replace index in for loop with direct reference (
for-index-replacement)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!