Skip to content

Sourcery refactored master branch#4

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

Sourcery refactored master branch#4
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Jun 29, 2020

Copy link
Copy Markdown

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
Copy Markdown
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)

# Must return an iterable of Request, dict or Item objects.
for i in result:
yield i
yield from result

Copy link
Copy Markdown
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
Copy Markdown
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)

for spidername in args or spider_loader.list():
#if 'comment' in spidername: # 只并行爬取comment
if (spidername == 'douban-comment225') or (spidername == 'douban-comment250'):
if spidername in ['douban-comment225', 'douban-comment250']:

Copy link
Copy Markdown
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

sourcery-ai Bot commented Jun 29, 2020

Copy link
Copy Markdown
Author

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