thestudentlife/Manhattan-Project

View on GitHub

Showing 13 of 29 total issues

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

from django.contrib.auth import authenticate, login as do_login, logout as do_logout
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.models import Group, User
from django.template.loader import render_to_string
from django.shortcuts import render, redirect, get_object_or_404
Severity: Minor
Found in workflow/views.py - About 3 hrs to fix

Function front has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def front(request):
    if request.method == "GET":
        latest_articles_for_front = list(Article.objects.filter(published=True).order_by('-published_date')[:40])
        fronts = FrontArticle.objects.all()
        for front in fronts:
Severity: Minor
Found in workflow/views.py - About 2 hrs 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 manage_one has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def manage_one(request,user_id):
    user = get_object_or_404(User,pk=user_id)
    if request.method=='GET':
        form = RegisterForm2(instance=user)
        second_form = ProfileForm(instance=user.profile)
Severity: Minor
Found in workflow/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 assignments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def assignments(request):
    if request.is_ajax():
        if request.GET['action']=='accept':
            asgt = Assignment.objects.get(id=int(request.GET['id']))
            asgt.accepted=True
Severity: Minor
Found in workflow/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 register has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def register(request):
    if request.method == "POST":
        registerForm = RegisterForm(request.POST)
        if registerForm.is_valid():
            user = registerForm.save()
Severity: Minor
Found in workflow/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 section has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def section(request, section_slug):
    sections = Section.objects.all().order_by('priority')
    this_section = 0
    for section in sections:
        if section.slug() == section_slug:
Severity: Minor
Found in mainsite/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 login has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def login(request):
    if request.method == "POST":
        loginForm = LoginForm(request.POST)
        username = request.POST['username']
        password = request.POST['password']
Severity: Minor
Found in workflow/views.py - About 55 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 article_edit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def article_edit(request, issue_id, pk):
    article = Article.objects.get(pk=pk)
    locked_by = request.user in article.edited_by.all()
    if request.method == 'GET':
        original_time = article.updated_date.second
Severity: Minor
Found in workflow/article_views.py - About 55 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 new_assignment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def new_assignment(request):
    if request.method == 'GET':
        form = AssignmentForm()
        return render(request, 'assignment/new_assignment.html', {'form': form})
    else:
Severity: Minor
Found in workflow/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 home has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def home(request):
    features = CarouselArticle.objects.all()
    fronts = list(map(lambda x: x.article, FrontArticle.objects.order_by("article__section__priority").all()))
    comics = Article.objects.filter(title__startswith="Weekly Comic").order_by('-created_date')
    comic_url = None
Severity: Minor
Found in mainsite/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

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

def setting(request,user_id):
    if request.user.id != int(user_id):
        return render(request,'permission.html')
    user = User.objects.get(pk=user_id)
    if request.method=='GET':
Severity: Minor
Found in workflow/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

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

def get_old_profile(display_name):
    old_profile = None
    if Profile.objects.filter(display_name=display_name)!=0:
        profiles = Profile.objects.filter(display_name=display_name)
        for profile in profiles:
Severity: Minor
Found in workflow/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

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

def person(request, person_id, person_name='ZQ'):
    person = get_object_or_404(Profile, pk=person_id)
    if person.position == "author" or len(person.article_set.all().filter(published=True)) > 0:
        articles = person.article_set.all().filter(published=True)
        recents = person.article_set.all().filter(published=True).order_by('-published_date')[:5]
Severity: Minor
Found in mainsite/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