Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main
Open

Sourcery refactored main branch#1
sourcery-ai[bot] wants to merge 1 commit into
mainfrom
sourcery/main

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Dec 30, 2021

Copy link
Copy Markdown

Branch main 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 main branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from dishantr16 December 30, 2021 17:37
Comment thread ecommerce/store/models.py
Comment on lines -42 to +43
shipping = False
orderitems = self.orderitem_set.all()
for i in orderitems:
if i.product.digital == False:
shipping = True
return shipping
return any(i.product.digital == False for i in orderitems)

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 Order.shipping refactored with the following changes:

Comment thread ecommerce/store/models.py
Comment on lines -52 to +48
total = sum([item.get_total for item in orderitems])
return total
return sum(item.get_total for item in orderitems)

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 Order.get_cart_total refactored with the following changes:

Comment thread ecommerce/store/models.py
Comment on lines -58 to +53
total = sum([item.quantity for item in orderitems])
return total
return sum(item.quantity for item in orderitems)

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 Order.get_cart_items refactored with the following changes:

Comment thread ecommerce/store/models.py
Comment on lines -69 to +63
total = self.product.price * self.quantity
return total
return self.product.price * self.quantity

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 OrderItem.get_total refactored with the following changes:

Comment thread ecommerce/store/utils.py
cartItems = order['get_cart_items']

for i in cart:
for i, value in cart.items():

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 cookieCart refactored with the following changes:

@sourcery-ai

sourcery-ai Bot commented Dec 30, 2021

Copy link
Copy Markdown
Author

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 2.42 ⭐ 2.37 ⭐ -0.05 👍
Method Length 31.93 ⭐ 31.07 ⭐ -0.86 👍
Working memory 6.77 🙂 6.83 🙂 0.06 👎
Quality 78.48% 77.76% -0.72% 👎
Other metrics Before After Change
Lines 126 119 -7
Changed files Quality Before Quality After Quality Change
ecommerce/store/models.py 95.40% ⭐ 98.39% ⭐ 2.99% 👍
ecommerce/store/utils.py 67.32% 🙂 67.22% 🙂 -0.10% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
ecommerce/store/utils.py cookieCart 6 ⭐ 135 😞 10 😞 58.64% 🙂 Try splitting into smaller methods. Extract out complex expressions

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