Showing 186 of 349 total issues
Function purchase
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def purchase(user, account, items):
assert(hasattr(user, "id"))
assert(len(items) > 0)
# Give discounts based on user type
- 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 _history_mapper
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def _history_mapper(local_mapper):
cls = local_mapper.class_
# set the "active_history" flag
# on on column-mapped attributes so that the old version
- 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 admin_restock
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def admin_restock(request):
restock_items = ''
rows = 0
global_cost = Decimal(0)
donation = Decimal(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
File export_transactions.py
has 335 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!./venv/bin/python
# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/commandline.html#writing-a-script
from pyramid.paster import bootstrap
User
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class User(account.Account):
__tablename__ = 'users'
__mapper_args__ = {'polymorphic_identity': 'user'}
id = Column(Integer, ForeignKey("accounts.id"), primary_key=True)
Function item_sale_speed
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def item_sale_speed(num_days, only_item_id=None):
# TODO: If we're only looking for one item (only_item_id), this can probably
# be made more efficient
# First we need to figure out when each item was in stock and when it wasn't.
- 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 chezbetty-admin.js
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* Functions to manipulate price strings and numbers.
*/
function format_price (price) {
p = price.toFixed(2);
File user.py
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
from pyramid.security import authenticated_userid
import hashlib
import binascii
import os
from .model import *
Function admin_user_balance_edit_submit
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def admin_user_balance_edit_submit(request):
try:
if request.POST['sender-search-choice'] == 'chezbetty':
sender = 'chezbetty'
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 _send_email
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def _send_email(msg, FROM):
settings = get_current_registry().settings
if suppress_emails():
print("Mail suppressed due to debug settings")
- 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 utility.py
has 303 lines of code (exceeds 250 allowed). Consider refactoring. Open
from decimal import Decimal
import itertools
import qrcode
import qrcode.image.svg
import stripe
File views_terminal.py
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
from pyramid.events import subscriber
from pyramid.events import BeforeRender
from pyramid.httpexceptions import HTTPFound
from pyramid.renderers import render
from pyramid.renderers import render_to_response
Function user_balance_histogram
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def user_balance_histogram ():
bin_size = 5 # $5
bins = {}
def to_bin (x):
- 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 group
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def group(rows, period='day'):
def fix_timezone(i):
return i.timestamp.to('America/Detroit')
def group_month(i):
- 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 _admin_ajax_general
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def _admin_ajax_general(request, obj_value):
obj_str = request.matchdict['object']
obj_id = int(request.matchdict['id'])
obj_field = request.matchdict['field']
- 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 admin_user_purchase_add_submit
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def admin_user_purchase_add_submit(request):
try:
# Get the user from the POST data
user = User.from_id(int(re.sub("[^0-9]", "", request.POST['user-search-choice'])))
- 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 admin_index
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def admin_index(request):
events = Event.some(10)
users_shame = DBSession.query(User)\
.filter(User.balance < 0)\
.order_by(User.balance)\
Function terminal
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def terminal(request):
try:
if len(request.matchdict['umid']) != 8:
raise __user.InvalidUserException()
- 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 login_submit
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def login_submit(request):
# Need to set this in case the password is wrong
came_from = request.params.get('came_from', request.url)
messages = []
- 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 admin_dashboard
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def admin_dashboard(request):
bsi = DBSession.query(func.sum(PurchaseLineItem.quantity).label('quantity'), Item)\
.join(Item)\
.join(Transaction)\