Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jan 30, 2022

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from harunpehlivan January 30, 2022 06:25
@secureflag-knowledge-base
Copy link

No description provided.

for i in xrange(2):
for _ in xrange(2):
Copy link
Author

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:

for i in range(n):
for _ in range(n):
Copy link
Author

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:

if delta_time == 0:
return 'very high!'
else:
return value / delta_time
return 'very high!' if delta_time == 0 else value / delta_time
Copy link
Author

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:

Comment on lines -1037 to +1034
# 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):
Copy link
Author

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:

This removes the following comments ( why? ):

# After we obtain the lock, make sure the site hasn't already been created.

Comment on lines -1074 to +1069
res = self._get_site_id_from_hit_host(hit)
if res:
if res := self._get_site_id_from_hit_host(hit):
Copy link
Author

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:

Comment on lines -1173 to +1167
hits_by_client = [[] for r in cls.recorders]
hits_by_client = [[] for _ in cls.recorders]
Copy link
Author

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:

Comment on lines -1449 to +1447
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
)

Copy link
Author

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)

Comment on lines -1506 to +1501
lineno = lineno + 1
lineno += 1
Copy link
Author

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)

Comment on lines -9 to +12
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')
Copy link
Author

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:

Comment on lines -188 to +186

file = open(file_)
match = format.check_format(file)
file.close()


with open(file_) as file:
match = format.check_format(file)
Copy link
Author

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:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jan 30, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.03%.

Quality metrics Before After Change
Complexity 3.07 ⭐ 3.00 ⭐ -0.07 👍
Method Length 50.53 ⭐ 50.37 ⭐ -0.16 👍
Working memory 5.82 ⭐ 5.83 ⭐ 0.01 👎
Quality 76.85% 76.82% -0.03% 👎
Other metrics Before After Change
Lines 1311 1300 -11
Changed files Quality Before Quality After Quality Change
misc/log-analytics/import_logs.py 75.87% ⭐ 75.90% ⭐ 0.03% 👍
misc/log-analytics/tests/tests.py 78.94% ⭐ 78.78% ⭐ -0.16% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
misc/log-analytics/import_logs.py Recorder._get_hit_args 19 😞 247 ⛔ 11 😞 36.36% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
misc/log-analytics/import_logs.py DynamicResolver._add_site 9 🙂 126 😞 11 😞 54.96% 🙂 Try splitting into smaller methods. Extract out complex expressions
misc/log-analytics/import_logs.py Configuration._create_parser 0 ⭐ 507 ⛔ 7 🙂 56.81% 🙂 Try splitting into smaller methods
misc/log-analytics/import_logs.py Piwik._call_api 11 🙂 126 😞 8 🙂 59.30% 🙂 Try splitting into smaller methods
misc/log-analytics/tests/tests.py test_replay_tracking_arguments 0 ⭐ 698 ⛔ 5 ⭐ 61.45% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants