fga-gpp-mds/2016.2-SME_UnB

View on GitHub
src/users/views.py

Summary

Maintainability
B
5 hrs
Test Coverage

File views.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.contrib.auth import authenticate
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User, Permission
Severity: Minor
Found in src/users/views.py - About 3 hrs to fix

    Function register has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def register(request):
    
        if request.method == "GET":
            return render(request, 'userRegister/register.html')
        else:
    Severity: Minor
    Found in src/users/views.py - About 1 hr 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 edit_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def edit_user(request, user_id):
    
        user = User.objects.get(id=user_id)
    
        if request.method == "GET":
    Severity: Minor
    Found in src/users/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(request, 'users/dashboard.html')
    Severity: Major
    Found in src/users/views.py - About 30 mins to fix

      Error: inconsistent use of tabs and spaces in indentation (<unknown>, line 145)</unknown>
      Open

          from django.core import mail
      Severity: Minor
      Found in src/users/views.py by radon

      We encountered an error attempting to analyze this line.

      There are no issues that match your filters.

      Category
      Status