Showing 56 of 130 total issues
Function api_send
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def api_send(request):
response = {}
errors = []
if request.method == 'POST' and 'wallet' in request.POST and \
'address' in request.POST and \
- 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 newwallet
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
newwallet: function() {
this.errors = [];
if (this.walletname.length <= 30) {
var r = new XMLHttpRequest();
r.open('POST', newwallet_url, true);
Function setUp
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setUp(self):
self.u1 = User.objects.create_user('____u1', '', 'passw0rd')
self.u1.save()
self.u2 = User.objects.create_user('____u2', '', 'passw0rd')
self.u2.save()
Function api_checkaddress
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def api_checkaddress(request):
response = {'status': ""}
errors = []
if 'address' in request.GET:
validate = cm.validateaddress(request.GET['address'])
- 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 google_settings
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def google_settings(request):
args = {}
if request.method == 'POST':
if 'authcode' in request.POST and \
request.user.userextra.authenticator_id:
- 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 insert_text_field
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
insert_text_field: function( context ) {
var $text_field = $( '<input type="text"></input>' );
if ( settings['copy-attributes-to-text-field'] ) {
var attrs = {};
var raw_attrs = context.$select_field[0].attributes;
Function get_shipping_price
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_shipping_price(self, address=None):
if self.free_shipping or not self.physical:
return 0
if self.ships_from == address.country:
if self.price_currency != 'OK':
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
def buy(self):
purchase = Purchase(by=self.user, shipped_to=self.shipping)
for item in self.cart.cartentry_set.all():
if self.user.userextra.can_purchase_item(item.product):
purchase_item = item.product.buy(self.shipping, self.wallet,
- 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 sendto
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
sendto: function() {
this.errors = [];
this.checklength();
this.checkammount();
if (this.validaddress && this.validammount && this.validlength) {
Consider simplifying this complex logical expression. Open
if request.POST.get('shipping', False) and \
request.user.physicaladdress_set \
.filter(id=request.POST.get('shipping', 0)).count() >= 1:
chkout.shipping = request.user.physicaladdress_set.get(
id=request.POST.get('shipping', 0))
Consider simplifying this complex logical expression. Open
if chkout.step == 0:
if request.POST.get('shipping', False) and \
request.user.physicaladdress_set \
.filter(id=request.POST.get('shipping', 0)).count() >= 1:
chkout.shipping = request.user.physicaladdress_set.get(
Function upload_file_noapi
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def upload_file_noapi(request, id):
product = get_object_or_404(Product, id=id, physical=False,
seller=request.user)
if 'file' in request.FILES and \
0 < len(request.POST.get('name', '')) <= 200:
- 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 newwallet
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
newwallet: function() {
this.errors = [];
if (this.walletname.length <= 30) {
var r = new XMLHttpRequest();
r.open('POST', newwallet_url, 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 add_to_cart
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add_to_cart(request, id):
cart = request.user.cart
product = get_object_or_404(Product, id=id, approved=True, removed=False)
if request.user.userextra.can_purchase_item(product):
if product.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 sendto
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
sendto: function() {
this.errors = [];
this.checklength();
this.checkammount();
if (this.validaddress && this.validammount && this.validlength) {
- 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 register_view
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def register_view(request):
if request.method == 'POST':
form = RegisterForm(request.POST)
if form.is_valid():
messages.success(request,
- 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 deeply nested control flow statements. Open
if i.uuid not in request.POST.getlist('images', []):
i.delete()
else:
Avoid deeply nested control flow statements. Open
if user.userextra.verify_2fa(
request.POST.get('2facode', '')):
login(request, user)
messages.success(request,
"Welcome back, %s!" % user.username)
Avoid deeply nested control flow statements. Open
for item in chkout.cart.cartentry_set.all():
t = False
if not item.product.ships_to(chkout.shipping):
messages.warning(
request,
Avoid deeply nested control flow statements. Open
if chkout.step <= 1 and len(addresses) > 0:
chkout.step = 1
else:
messages.warning(request, "Not enough balance!")
return redirect("shop:cart")