-
Notifications
You must be signed in to change notification settings - Fork 27
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 #27
Conversation
|
||
import os | ||
import pathlib | ||
import sys | ||
|
||
if sys.platform == "win32": | ||
klayout_folder = "KLayout" | ||
else: | ||
klayout_folder = ".klayout" | ||
|
||
|
||
klayout_folder = "KLayout" if sys.platform == "win32" else ".klayout" |
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.
Lines 6-11
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
dl = (np.arccos(2 * power_per_cent / 100 - 1)) / beta | ||
return dl | ||
return (np.arccos(2 * power_per_cent / 100 - 1)) / beta |
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_length
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if n == 4 and label in ["opt1", "opt2"]: | ||
return 180 | ||
if n == 4 and label in ["opt3", "opt4"]: | ||
return 0 | ||
if n == 4: | ||
if label in {"opt1", "opt2"}: | ||
return 180 | ||
if label in {"opt3", "opt4"}: | ||
return 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 guess_port_orientaton
refactored with the following changes:
- Hoist a repeated condition into a parent condition. (
hoist-repeated-if-condition
) - Use set when checking membership of a collection of literals (
collection-into-set
)
n = 0 | ||
for label in c.get_labels(): | ||
if label.text.startswith("opt"): | ||
n += 1 | ||
|
||
n = sum(1 for label in c.get_labels() if label.text.startswith("opt")) |
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 add_ports
refactored with the following changes:
- Convert for loop into call to sum() (
sum-comprehension
)
model = c.name if not model else model | ||
model = model or c.name |
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 add_siepic_labels_and_simulation_info
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
e = [] | ||
e.append( | ||
e = [ |
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_mask2
refactored with the following changes:
- Merge append into list declaration (
merge-list-append
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.33%.
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! |
Kudos, SonarCloud Quality Gate passed!
|
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
==========================================
+ Coverage 57.09% 57.28% +0.18%
==========================================
Files 27 27
Lines 627 625 -2
==========================================
Hits 358 358
+ Misses 269 267 -2
Continue to review full report at Codecov.
|
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!