-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2
base: master
Are you sure you want to change the base?
Conversation
No description provided. |
for i in xrange(2): | ||
for _ in xrange(2): |
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 IisFormat.check_format
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
for i in range(n): | ||
for _ in range(n): |
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 Statistics.Counter.advance
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
if delta_time == 0: | ||
return 'very high!' | ||
else: | ||
return value / delta_time | ||
return 'very high!' if delta_time == 0 else value / delta_time |
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 Statistics._compute_speed
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
# After we obtain the lock, make sure the site hasn't already been created. | ||
res = self._get_site_id_from_hit_host(hit) | ||
if res: | ||
if res := self._get_site_id_from_hit_host(hit): |
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 DynamicResolver._add_site
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
This removes the following comments ( why? ):
# After we obtain the lock, make sure the site hasn't already been created.
res = self._get_site_id_from_hit_host(hit) | ||
if res: | ||
if res := self._get_site_id_from_hit_host(hit): |
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 DynamicResolver._resolve
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
hits_by_client = [[] for r in cls.recorders] | ||
hits_by_client = [[] for _ in cls.recorders] |
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 Recorder.add_hits
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
for included_path in config.options.included_paths: | ||
if fnmatch.fnmatch(hit.path, included_path): | ||
return True | ||
return False | ||
return any( | ||
fnmatch.fnmatch(hit.path, included_path) | ||
for included_path in config.options.included_paths | ||
) | ||
|
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 Parser.check_path
refactored with the following changes:
- Use any() instead of for loop (
use-any
)
lineno = lineno + 1 | ||
lineno += 1 |
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 Parser.detect_format
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
file = open(path) | ||
contents = file.read() | ||
file.close() | ||
|
||
file = open('tmp.log', 'w') | ||
file.write(contents + ' junk') | ||
file.close() | ||
|
||
with open(path) as file: | ||
contents = file.read() | ||
with open('tmp.log', 'w') as file: | ||
file.write(contents + ' junk') |
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_junk_to_file
refactored with the following changes:
- Use
with
when opening file to ensure closure (ensure-file-closed
)
|
||
file = open(file_) | ||
match = format.check_format(file) | ||
file.close() | ||
|
||
|
||
with open(file_) as file: | ||
match = format.check_format(file) |
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 parse_log_file_line
refactored with the following changes:
- Use
with
when opening file to ensure closure (ensure-file-closed
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.03%.
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! |
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!