hack4impact/flask-base

View on GitHub

Showing 8 of 33 total issues

Function create_app has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def create_app(config):
    app = Flask(__name__)
    config_name = config

    if not isinstance(config, str):
Severity: Minor
Found in app/__init__.py - About 1 hr to fix

Function join_from_invite has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def join_from_invite(user_id, token):
    """
    Confirm new user's account with provided token and prompt them to set
    a password.
    """
Severity: Minor
Found in app/account/views.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function reset_password has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def reset_password(token):
    """Reset an existing user's password."""
    if not current_user.is_anonymous:
        return redirect(url_for('main.index'))
    form = ResetPasswordForm()
Severity: Minor
Found in app/account/views.py - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid too many return statements within this function.
Open

    return render_template('account/reset_password.html', form=form)
Severity: Major
Found in app/account/views.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return render_template('account/join_invite.html', form=form)
Severity: Major
Found in app/account/views.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return redirect(url_for('main.index'))
Severity: Major
Found in app/account/views.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return True
Severity: Major
Found in app/models/user.py - About 30 mins to fix

Function login has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def login():
    """Log in an existing user."""
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
Severity: Minor
Found in app/account/views.py - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Severity
Category
Status
Source
Language