Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Sourcery refactored master branch #1

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 28, 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 -63 to +66
thumbnail_format = '100x100'
picture = obj.get_default_picture()

if picture:
thumbnail_format = '100x100'
Copy link
Author

Choose a reason for hiding this comment

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

Function ArtworkAdmin.thumbnail refactored with the following changes:

  • Move assignments closer to their usage (move-assign)

obj = Category(slug=slug, title=title)

return obj
return Category(slug=slug, title=title)
Copy link
Author

Choose a reason for hiding this comment

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

Function PortfolioTestBase.create_category refactored with the following changes:

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

Comment on lines -46 to +44
obj = Collection(slug=slug, title=title)

return obj
return Collection(slug=slug, title=title)
Copy link
Author

Choose a reason for hiding this comment

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

Function PortfolioTestBase.create_collection refactored with the following changes:

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

Comment on lines -57 to +53
obj = Artwork(collection=collection)

return obj
return Artwork(collection=collection)
Copy link
Author

Choose a reason for hiding this comment

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

Function PortfolioTestBase.create_artwork refactored with the following changes:

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

Comment on lines -68 to +62
obj = Picture(artwork=artwork, title=title)
return obj
return Picture(artwork=artwork, title=title)
Copy link
Author

Choose a reason for hiding this comment

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

Function PortfolioTestBase.create_picture refactored with the following changes:

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

Comment on lines -442 to +435
if not expected_admin or not expected_inline:
if not (expected_admin and expected_inline):
Copy link
Author

Choose a reason for hiding this comment

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

Function EditorTestBase.test_admin refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

if next:
default_ordering = 'ASC'
else:
default_ordering = 'DESC'

default_ordering = 'ASC' if next else 'DESC'
Copy link
Author

Choose a reason for hiding this comment

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

Function get_next_or_previous refactored with the following changes:

  • Replace if statement with if expression (assign-if-exp)
  • Simplify logical expression using De Morgan identities (de-morgan)

object_list = models.Category.objects.all()[offset:offset+limit]
return object_list
return models.Category.objects.all()[offset:offset+limit]
Copy link
Author

Choose a reason for hiding this comment

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

Function categories refactored with the following changes:

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

Comment on lines 59 to 60
object_list = models.Collection.objects.all()[offset:offset+limit]
return object_list No newline at end of file
return models.Collection.objects.all()[offset:offset+limit]
Copy link
Author

Choose a reason for hiding this comment

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

Function collections refactored with the following changes:

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

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jun 28, 2020

Sourcery Code Quality Report (beta)

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

Before After Change
Quality 8.81 8.82 0.01
Complexity 0.7 0.68 -0.02
Method Length 47.64 47.17 -0.47
Lines 651 638 -13
Changed files Quality Before Quality After Quality Change
portfolio/admin.py 8.59 8.59 0.0
portfolio/tests.py 8.87 8.88 0.01 ⬆️
portfolio/utils.py 7.78 7.85 0.07 ⬆️
portfolio/templatetags/portfolio_tags.py 8.89 8.92 0.04 ⬆️

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

File Function Quality Recommendation
portfolio/tests.py PortfolioTagsTest.test_artworks_tag 6.06 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant