-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
Conversation
if not session.get('logged_in'): | ||
return flask.redirect(flask.url_for('.login')) | ||
else: | ||
return flask.redirect(flask.url_for('.dashboard_panel')) | ||
return ( | ||
flask.redirect(flask.url_for('.dashboard_panel')) | ||
if session.get('logged_in') | ||
else flask.redirect(flask.url_for('.login')) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main_page
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
if session.get('logged_in') is False: | ||
return flask.redirect(flask.url_for('.main_page')) | ||
else: | ||
if session.get('logged_in') is not False: | ||
session['logged_in'] = False | ||
flask_login.logout_user() | ||
return flask.redirect(flask.url_for('.main_page')) | ||
return flask.redirect(flask.url_for('.main_page')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function logout
refactored with the following changes:
- Hoist nested repeated code outside conditional statements (
hoist-similar-statement-from-if
)
return flask.flash('Error: %s' % errorIndication) | ||
return flask.flash(f'Error: {errorIndication}') | ||
elif errorStatus: | ||
return flask.flash( | ||
'%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex) - 1] or '?') | ||
f"{errorStatus.prettyPrint()} at {errorIndex and varBinds[int(errorIndex) - 1] or '?'}" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function MainAPI.get
refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.56%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
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! |
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:Help us improve this pull request!