Skip to content

Conversation

@sourcery-ai
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 -75 to +98
app = web.Application([
(r'/', IndexHandler),
(r'/posts', PostsHandler),
(r'/p/(.*)', PostHandler),
(r'/achive', AchiveHandler),
(r'/share', ShareHandler),
(r'/product', ProductHandler),
(r'/link', LinkHandler),
(r'/about', AboutHandler),
(r'/((js|css|image)/.*)', web.StaticFileHandler, dict(path=settings['static_path'])),
(r'/(.*\.(txt|html))', web.StaticFileHandler, dict(path=settings['static_path'])),
(r'.*', PageNotFoundHandler)
], **settings)
return app
return web.Application(
[
(r'/', IndexHandler),
(r'/posts', PostsHandler),
(r'/p/(.*)', PostHandler),
(r'/achive', AchiveHandler),
(r'/share', ShareHandler),
(r'/product', ProductHandler),
(r'/link', LinkHandler),
(r'/about', AboutHandler),
(
r'/((js|css|image)/.*)',
web.StaticFileHandler,
dict(path=settings['static_path']),
),
(
r'/(.*\.(txt|html))',
web.StaticFileHandler,
dict(path=settings['static_path']),
),
(r'.*', PageNotFoundHandler),
],
**settings
)
Copy link
Author

Choose a reason for hiding this comment

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

Function create_app refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

if url == post['id']:
found_post = True
break
found_post = any(url == post['id'] for post in options.config['posts'])
Copy link
Author

Choose a reason for hiding this comment

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

Function PostHandler.get refactored with the following changes:

  • Use any() instead of for loop (use-any)

if '.html' in post_file_name:
post = {}
post['title'] = post_file_name.replace('.html', '')
post = {'title': post_file_name.replace('.html', '')}
Copy link
Author

Choose a reason for hiding this comment

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

Function html2template refactored with the following changes:

  • Merge dictionary assignment with declaration (merge-dict-assign)

@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.02 out of 10.

Before After Change
Quality 8.61 8.63 0.02
Complexity 2.18 2.0 -0.18
Method Length 66.08 65.49 -0.59
Lines 236 241 5
Changed files Quality Before Quality After Quality Change
app/init.py 7.26 7.28 0.01 ⬆️
app/handler.py 9.3 9.34 0.03 ⬆️
app/html2template.py 7.36 7.37 0.0 ⬆️

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

File Function Quality Recommendation
app/html2template.py html2template 3.7 Split out functionality
app/init.py create_app 5.29 Split out functionality

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.

2 participants