-
Notifications
You must be signed in to change notification settings - Fork 2
Sourcery refactored master branch #9
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
| return False | ||
|
|
||
| return True | ||
| return all(num % i != 0 for i in range(2, num)) |
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_prime refactored with the following changes:
- Use any() instead of for loop (
use-any) - Invert any/all to simplify comparisons (
invert-any-all)
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.
Amazing!
| def first_unique_character(s): | ||
| before = '' | ||
| for i in range(0, len(s)): | ||
| for i in range(len(s)): |
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 first_unique_character refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range)
| return False | ||
|
|
||
| return True | ||
| return all(num % i != 0 for i in range(2, end)) |
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_prime refactored with the following changes:
- Use any() instead of for loop (
use-any) - Invert any/all to simplify comparisons (
invert-any-all)
| @app.task | ||
| def show(symbol, time_count): | ||
| for m in range(time_count): | ||
| for _ in range(time_count): |
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 show refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| if (self.p1points==0): | ||
| if self.p1points == 0: | ||
| result = "Love" | ||
| if (self.p1points==1): | ||
| elif self.p1points == 1: | ||
| result = "Fifteen" | ||
| if (self.p1points==2): | ||
| elif self.p1points == 2: | ||
| result = "Thirty" | ||
| if (self.p1points==3): | ||
| elif self.p1points == 3: | ||
| result = "Forty" | ||
| result += "-All" | ||
| if (self.p1points==self.p2points and self.p1points>3): | ||
| result = "Deuce" | ||
|
|
||
| P1res = "" | ||
| P2res = "" | ||
| if (self.p1points > 0 and self.p2points==0): | ||
| if (self.p1points==1): | ||
| if self.p1points == 1: | ||
| P1res = "Fifteen" | ||
| if (self.p1points==2): | ||
| elif self.p1points == 2: | ||
| P1res = "Thirty" | ||
| if (self.p1points==3): | ||
| elif self.p1points == 3: | ||
| P1res = "Forty" | ||
|
|
||
| P2res = "Love" | ||
| result = P1res + "-" + P2res | ||
| if (self.p2points > 0 and self.p1points==0): | ||
| if (self.p2points==1): | ||
| if self.p2points == 1: | ||
| P2res = "Fifteen" | ||
| if (self.p2points==2): | ||
| elif self.p2points == 2: | ||
| P2res = "Thirty" | ||
| if (self.p2points==3): | ||
| elif self.p2points == 3: | ||
| P2res = "Forty" | ||
|
|
||
| P1res = "Love" | ||
| result = P1res + "-" + P2res | ||
|
|
||
|
|
||
| if (self.p1points>self.p2points and self.p1points < 4): | ||
| if (self.p1points==2): | ||
| if self.p1points == 2: | ||
| P1res="Thirty" | ||
| if (self.p1points==3): | ||
| elif self.p1points == 3: | ||
| P1res="Forty" | ||
| if (self.p2points==1): | ||
| if self.p2points == 1: | ||
| P2res="Fifteen" | ||
| if (self.p2points==2): | ||
| elif self.p2points == 2: | ||
| P2res="Thirty" | ||
| result = P1res + "-" + P2res | ||
| if (self.p2points>self.p1points and self.p2points < 4): | ||
| if (self.p2points==2): | ||
| if self.p2points == 2: | ||
| P2res="Thirty" | ||
| if (self.p2points==3): | ||
| elif self.p2points == 3: | ||
| P2res="Forty" | ||
| if (self.p1points==1): | ||
| if self.p1points == 1: | ||
| P1res="Fifteen" | ||
| if (self.p1points==2): | ||
| elif self.p1points == 2: | ||
| P1res="Thirty" | ||
| result = P1res + "-" + P2res | ||
|
|
||
| if (self.p1points > self.p2points and self.p2points >= 3): | ||
| result = "Advantage " + self.player1Name | ||
|
|
||
| if (self.p2points > self.p1points and self.p1points >= 3): | ||
| result = "Advantage " + self.player2Name | ||
|
|
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 TennisGameDefactored2.score refactored with the following changes:
- Simplify conditional into switch-like form (
switch)
|
|
||
| def SetP1Score(self, number): | ||
| for i in range(number): | ||
| for _ in range(number): |
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 TennisGameDefactored2.SetP1Score refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
|
|
||
| def SetP2Score(self, number): | ||
| for i in range(number): | ||
| for _ in range(number): |
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 TennisGameDefactored2.SetP2Score refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| for i in range(p1_points): | ||
| for _ in range(p1_points): | ||
| game.won_point(p1_name) | ||
| for i in range(p2_points): | ||
| for _ in range(p2_points): |
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 test_get_score refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| def test_player_names(): | ||
| game = TennisGame('One', 'Two') | ||
| for i in range(4): | ||
| for _ in range(4): |
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 test_player_names refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.03 out of 10.
Here are some functions in these files that still need a tune-up:
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! |
Branch
masterrefactored 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
masterbranch, then run: