Showing 56 of 130 total issues
File views.py
has 1044 lines of code (exceeds 250 allowed). Consider refactoring. Open
# vim: ai ts=4 sts=4 et sw=4
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth import logout, authenticate, login
Function edit_product
has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring. Open
def edit_product(request, id):
product = get_object_or_404(Product, id=id, seller=request.user)
shipping_countries = []
for country in countries:
shipping_countries.append({'country': country,
- Read upRead up
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 checkout
has a Cognitive Complexity of 98 (exceeds 5 allowed). Consider refactoring. Open
def checkout(request):
if not hasattr(request.user, 'cart'):
c = Cart(user=request.user)
c.save()
if request.user.cart.has_something_in_stock():
- Read upRead up
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 sell_new_product
has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring. Open
def sell_new_product(request):
if request.method == 'POST':
# Get ready for all the ifs!
errors = []
- Read upRead up
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
File tests.py
has 653 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.test import TestCase, Client
from django.contrib.auth.models import User
from .models import *
from django.urls import reverse
from django.core.files.uploadedfile import SimpleUploadedFile
File models.py
has 628 lines of code (exceeds 250 allowed). Consider refactoring. Open
import uuid
import os
from django.db import models
from django.db.models import F
Function login_view
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def login_view(request):
if request.method == 'POST':
if 'username' in request.POST and 'password' in request.POST:
username = request.POST['username']
password = request.POST['password']
- Read upRead up
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 jquery_ui
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
jquery_ui: function( context ) {
// loose matching of search terms
var filter_options = function( term ) {
var split_term = term.split(' ');
var matchers = [];
Function manage_keyset
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def manage_keyset(request, id, keyid=None):
context = {}
if keyid is not None:
keyset = get_object_or_404(DigitalKeySet, id=keyid,
- Read upRead up
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_order
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def manage_order(request, id):
order = get_object_or_404(PurchaseItem, product__seller=request.user,
id=id, product__physical=True)
if request.method == 'POST':
- Read upRead up
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 change_password
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def change_password(request):
if request.method == 'POST':
errors = []
curpass = request.POST.get('curpassword', '')
- Read upRead up
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 view_product
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def view_product(request, id):
product = get_object_or_404(Product, id=id, approved=True)
if request.method == 'POST':
- Read upRead up
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 buy
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def buy(self, address, wallet, ammount, gift=False):
if not hasattr(self.seller, 'usershop'):
if self.seller.wallet_set.filter(active=True).count() > 0:
a = self.seller.wallet_set.filter(active=True).first()
else:
- Read upRead up
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 checkaddrlength
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
checkaddrlength: function() {
this.validlength = this.to_address.length == 34
if (this.to_address.length == 34) {
var r = new XMLHttpRequest();
r.open('GET', checkaddr_url+'?address='+this.to_address, true);
- Read upRead up
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 editshop
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def editshop(request):
if request.method == 'POST' and hasattr(request.user, 'usershop'):
if 'description' in request.POST:
request.user.usershop.description = request.POST['description']
if 'css' in request.POST and request.user.usershop.can_customcss:
- Read upRead up
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 extract_options
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
extract_options: function( $select_field ) {
var options = [];
var $options = $select_field.find('option');
var number_of_options = $options.length;
Function filter_options
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
var filter_options = function( term ) {
var split_term = term.split(' ');
var matchers = [];
for (var i=0; i < split_term.length; i++) {
if ( split_term[i].length > 0 ) {
Function authorize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def authorize(request, forid):
if request.method == 'POST' and 'password' in request.POST:
u = authenticate(username=request.user.username,
password=request.POST.get('password', ''))
if u is not None:
- Read upRead up
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 send_to
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def send_to(self, address, ammount):
response = {}
errors = []
if Wallet.objects.filter(address=address).count() > 0:
- Read upRead up
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 toggle_vote
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def toggle_vote(request, id, vote):
review = get_object_or_404(Review, id=id)
if ReviewVote.objects.filter(user=request.user, review=review).count():
rv = ReviewVote.objects.get(user=request.user, review=review)
- Read upRead up
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"