Skip to content

Sourcery Starbot ⭐ refactored dericf/twitter-clone-server-fastapi#13

Open
SourceryAI wants to merge 1 commit into
dericf:masterfrom
SourceryAI:master
Open

Sourcery Starbot ⭐ refactored dericf/twitter-clone-server-fastapi#13
SourceryAI wants to merge 1 commit into
dericf:masterfrom
SourceryAI:master

Conversation

@SourceryAI
Copy link
Copy Markdown

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/twitter-clone-server-fastapi master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment thread api/crud.py
Comment on lines -151 to -154
# user exists - proceed to return tweets
tweets = db.query(models.Tweet).filter(models.Tweet.user_id == user_id).order_by(
return db.query(models.Tweet).filter(models.Tweet.user_id == user_id).order_by(
models.Tweet.created_at.desc()).limit(limit).all()
return tweets
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 get_tweets_for_user refactored with the following changes:

This removes the following comments ( why? ):

# user exists - proceed to return tweets

Comment thread api/crud.py
Comment on lines -393 to -396
# User is valid - proceed to get all followers
db_followers = db.query(models.Follows).filter(
return db.query(models.Follows).filter(
models.Follows.follows_user_id == user_id).all()
return db_followers
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 get_all_followers refactored with the following changes:

This removes the following comments ( why? ):

# User is valid - proceed to get all followers

Comment thread api/core/security.py
Comment on lines -36 to -38
encoded_jwt = jwt.encode(
return jwt.encode(
to_encode, settings.SECRET_KEY, algorithm=ALGORITHM)
return encoded_jwt
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 create_access_token refactored with the following changes:

Comment thread api/routers/users.py
# Update user attributes
user = crud.update_user(db, current_user.id, request_body)
return user
return crud.update_user(db, current_user.id, request_body)
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 update_user refactored with the following changes:

This removes the following comments ( why? ):

# Update user attributes

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 1, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.13%.

Quality metrics Before After Change
Complexity 1.29 ⭐ 1.28 ⭐ -0.01 👍
Method Length 41.19 ⭐ 41.00 ⭐ -0.19 👍
Working memory 7.44 🙂 7.41 🙂 -0.03 👍
Quality 80.75% 80.88% 0.13% 👍
Other metrics Before After Change
Lines 696 689 -7
Changed files Quality Before Quality After Quality Change
api/crud.py 80.97% ⭐ 81.05% ⭐ 0.08% 👍
api/core/security.py 87.42% ⭐ 87.97% ⭐ 0.55% 👍
api/routers/users.py 75.35% ⭐ 75.62% ⭐ 0.27% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
api/routers/users.py get_one_or_all_users 2 ⭐ 68 🙂 13 😞 66.46% 🙂 Extract out complex expressions
api/routers/users.py update_user 4 ⭐ 71 🙂 10 😞 69.22% 🙂 Extract out complex expressions
api/crud.py create_user 0 ⭐ 63 🙂 13 😞 69.23% 🙂 Extract out complex expressions
api/crud.py get_tweets_liked_by_user 1 ⭐ 72 🙂 11 😞 70.16% 🙂 Extract out complex expressions
api/routers/users.py get_one_or_all_users 0 ⭐ 57 ⭐ 13 😞 70.17% 🙂 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.

1 participant