Showing 56 of 130 total issues
Avoid deeply nested control flow statements. Open
if chkout.get_price() == Decimal(0) and\
len(addresses) == 0:
a = Wallet(user=request.user, label='default')
a.save()
chkout.wallet = a
Avoid deeply nested control flow statements. Open
if p.product is None:
p.product = product
p.save()
except ObjectDoesNotExist:
Avoid deeply nested control flow statements. Open
if country in dict(countries):
c = ShippingCountry(country=country, product=p)
c.save()
p.save()
Avoid deeply nested control flow statements. Open
if country not in dict(countries):
errors.append('%s is not a country!' % country)
else:
sc = ShippingCountry(product=product, country=country)
sc.save()
Avoid deeply nested control flow statements. Open
if country not in dict(countries):
errors.append('%s is not a country!' % country)
if 'free-shipping' in request.POST:
Avoid deeply nested control flow statements. Open
if 0 < len(request.POST['zip'].strip()) <= 15 and\
0 < len(request.POST['name'].strip()) <= 200 and\
request.POST['address1'].strip() != '' and\
request.POST['country'].strip() in dict(countries)\
and request.POST['state'].strip() != '':
Function upload_file
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def upload_file(request, id):
product = get_object_or_404(Product, id=id, physical=False)
if product.seller != request.user:
e = {
'status': 403,
- 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 shop
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def shop(request, user):
try:
usershop = get_object_or_404(UserShop, user__username=user)
except Http404:
if User.objects.filter(username=user).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
Avoid too many return
statements within this function. Open
return self.outside_price
Avoid too many return
statements within this function. Open
return render(request, 'shop/checkout2.html',
Avoid too many return
statements within this function. Open
return redirect('shop:cart')
Avoid too many return
statements within this function. Open
return -self.get_score()
Avoid too many return
statements within this function. Open
return render(request, 'shop/checkout3.html', {'checkout': chkout})
Function get_shipping_price
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_shipping_price(self):
if not self.cached_shipping:
s = 0
for item in self.cart.cartentry_set.filter(
product__stock__gte=F('quantity'), product__physical=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 get_key
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_key(request):
if request.method == 'POST' and 'purchaseid' in request.POST and \
'keyid' in request.POST:
try:
purchase = PurchaseItem.objects.get(purchase__by=request.user,
- 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 api_newwallet
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def api_newwallet(request):
response = {'status': ""}
errors = []
if request.method == 'POST' and 'wallet_name' in request.POST:
if len(request.POST['wallet_name']) > 30:
- 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"