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 #4

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 Jun 29, 2020

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^

Comment on lines -18 to +23
if args in _dnscache:
# print str(args) + " in cache"
return _dnscache[args]
else:
if args not in _dnscache:
# print str(args) + " not in cache"
_dnscache[args] = socket._getaddrinfo(*args, **kwargs)
return _dnscache[args]

# print str(args) + " in cache"
return _dnscache[args]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _setDNSCache._getaddrinfo refactored with the following changes:

  • Hoist repeated code outside conditional statement (hoist-statement-from-if)
  • Swap if/else to remove empty if body (remove-pass-body)

for i in result:
yield i
yield from result
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DoubanMovieSpiderMiddleware.process_spider_output refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

Comment on lines -98 to +97
for r in start_requests:
yield r
yield from start_requests
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DoubanMovieSpiderMiddleware.process_start_requests refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

if (spidername == 'douban-comment225') or (spidername == 'douban-comment250'):
if spidername in ['douban-comment225', 'douban-comment250']:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Command.run refactored with the following changes:

  • Replace multiple comparisons of same variable with in operator (merge-comparisons)

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jun 29, 2020

Sourcery Code Quality Report (beta)

✅ Merging this PR will increase code quality in the affected files by 0.06 out of 10.

Before After Change
Quality 9.31 9.36 0.06
Complexity 1.0 0.71 -0.29
Method Length 24.09 23.04 -1.06
Lines 134 130 -4
Changed files Quality Before Quality After Quality Change
douban_movie/douban_movie/dns_cache.py 9.09 9.24 0.15 ⬆️
douban_movie/douban_movie/middlewares.py 9.37 9.42 0.04 ⬆️
douban_movie/douban_movie/commands/crawlallcomment.py 9.32 9.35 0.03 ⬆️

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!

Let us know what you think of it via email or our Gitter!

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.

1 participant