um-cseg/chez-betty

View on GitHub
chezbetty/views_admin.py

Summary

Maintainability
F
3 wks
Test Coverage

File views_admin.py has 2793 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
Severity: Major
Found in chezbetty/views_admin.py - About 1 wk to fix

    Function admin_items_list has a Cognitive Complexity of 98 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_items_list(request):
        group = request.GET['group'] if 'group' in request.GET else 'active'
    
        if group == 'active':
            page  = 'active'
    Severity: Minor
    Found in chezbetty/views_admin.py - About 1 day 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 admin_restock_submit has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_restock_submit(request):
    
        # Array of (Item, quantity, total) tuples
        items_for_pricing = []
        # Keep track of the total number of items being restocked. We use
    Severity: Minor
    Found in chezbetty/views_admin.py - About 1 day 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 admin_box_edit_submit has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_box_edit_submit(request):
        try:
            box = Box.from_id(int(request.POST['box-id']))
    
            if not box.exists_barcode(request.POST['box-barcode'], box.id):
    Severity: Minor
    Found in chezbetty/views_admin.py - About 1 day 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 admin_item_edit has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_item_edit(request):
        try:
            try:
                purchase_limit = request.GET['purchase_limit']
                if purchase_limit.lower() == 'none':
    Severity: Minor
    Found in chezbetty/views_admin.py - About 1 day 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 admin_box_add_submit has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_box_add_submit(request):
        try:
            error = False
            items_empty_barcode = 0
    
    
    Severity: Minor
    Found in chezbetty/views_admin.py - About 7 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 admin_item_edit_submit has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_item_edit_submit(request):
        try:
            item = Item.from_id(int(request.POST['item-id']))
    
            for key in request.POST:
    Severity: Minor
    Found in chezbetty/views_admin.py - About 7 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 admin_btc_reconcile has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_btc_reconcile(request):
        try:
            btc_balance = Bitcoin.get_balance()
            btc = {"btc": btc_balance,
                   "usd": btc_balance * Bitcoin.get_spot_price()}
    Severity: Minor
    Found in chezbetty/views_admin.py - About 6 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 admin_items_add_submit has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_items_add_submit(request):
        error_items = []
    
        # Iterate all the POST keys and find the ones that are item names
        for key in request.POST:
    Severity: Minor
    Found in chezbetty/views_admin.py - About 5 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 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)
    Severity: Minor
    Found in chezbetty/views_admin.py - About 4 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 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:
    Severity: Minor
    Found in chezbetty/views_admin.py - About 3 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 _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']
    
    
    Severity: Minor
    Found in chezbetty/views_admin.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 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'])))
    
    
    Severity: Minor
    Found in chezbetty/views_admin.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 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)\
    Severity: Major
    Found in chezbetty/views_admin.py - About 2 hrs to fix

      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)\
      Severity: Major
      Found in chezbetty/views_admin.py - About 2 hrs to fix

        Function admin_users_email_debt has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_users_email_debt(request):
            email_type = request.matchdict['type']
        
            if email_type == 'deadbeats':
                deadbeats = User.get_deadbeats()
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_item_search_json has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_item_search_json(request):
            try:
                boxes = Box.from_fuzzy(request.matchdict['search'])
                items = Item.from_fuzzy(request.matchdict['search'])
                box_vendors = BoxVendor.from_number_fuzzy(request.matchdict['search'])
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_item_barcode_pdf has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_item_barcode_pdf(request):
            try:
                item = Item.from_id(request.matchdict['item_id'])
                fname = '/tmp/{}.pdf'.format(item.id)
        
        
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_cash_reconcile_submit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_cash_reconcile_submit(request):
            try:
        
                if request.POST['cash-box-reconcile-type'] == 'cashboxtosafe':
                    if account.get_cash_account("cashbox").balance == Decimal('0'):
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_box_edit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_box_edit(request):
            try:
                box = Box.from_id(request.matchdict['box_id'])
                items = Item.all_force()
        
        
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_item_barcode_json has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_item_barcode_json(request):
            try:
                item = Item.from_barcode(request.matchdict['barcode'])
                html = render('templates/admin/restock_row.jinja2', {'item': item, 'line': {}})
                return {'status': 'success',
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_ajax_connection has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_ajax_connection(request):
            obj_str1 = request.matchdict['object1']
            obj_str2 = request.matchdict['object2']
            obj_arg1 = request.matchdict['arg1']
            obj_arg2 = request.matchdict['arg2']
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_users_email_purchasers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_users_email_purchasers(request):
            # Group all of the items into the correct structure
            items = []
            for key,value in request.POST.items():
                if key == 'item-id':
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_event_undo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_event_undo(request):
            try:
                # Lookup the transaction that the user wants to undo
                event = Event.from_id(request.matchdict['event_id'])
        
        
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_announcements_edit_submit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_announcements_edit_submit(request):
        
            # Group all the form items into a nice dict that we can cleanly iterate
            announcements = {}
            for key in request.POST:
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_inventory_submit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_inventory_submit(request):
            try:
                items = {}
                for key in request.POST:
                    try:
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_reimbursees_reimbursement_submit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_reimbursees_reimbursement_submit(request):
            try:
                reimbursee = Reimbursee.from_id(int(request.POST['reimbursee']))
                amount = Decimal(request.POST['amount'])
                notes = request.POST['notes']
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_boxes_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_boxes_list(request):
            unpopulated_boxes = []
            active_populated = []
            inactive_populated = []
        
        
        Severity: Minor
        Found in chezbetty/views_admin.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 admin_cash_withdrawal_submit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def admin_cash_withdrawal_submit(request):
            try:
                amount = Decimal(request.POST['amount'])
                reimbursee = Reimbursee.from_id(int(request.POST['reimbursee']))
        
        
        Severity: Minor
        Found in chezbetty/views_admin.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

        Avoid deeply nested control flow statements.
        Open

                                if quantity != '':
                                    # Add a new vendor to the item
                                    item = Item.from_id(item_id)
                                    box_item = BoxItem(box, item, quantity, round(Decimal(percentage), 2))
                                    DBSession.add(box_item)
        Severity: Major
        Found in chezbetty/views_admin.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if item_num != '':
                                      # Add a new vendor to the item
                                      vendor = Vendor.from_id(vendor_id)
                                      box_vendor = BoxVendor(vendor, box, item_num)
                                      DBSession.add(box_vendor)
          Severity: Major
          Found in chezbetty/views_admin.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if item_num == '':
                                        vendoritem.enabled = False
                                    else:
                                        vendoritem.item_number = item_num
                                    break
            Severity: Major
            Found in chezbetty/views_admin.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if output['addr'] in addrs and output['type'] == 0:
                                      addr = output['addr']
                                      amount += Decimal(output['value'])
              
              
              Severity: Major
              Found in chezbetty/views_admin.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if vendorbox.vendor_id == vendor_id and vendorbox.enabled:
                                            if item_num == '':
                                                vendorbox.enabled = False
                                            else:
                                                vendorbox.item_number = item_num
                Severity: Major
                Found in chezbetty/views_admin.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if boxitem.item_id == item_id and boxitem.enabled:
                                              if quantity == '' or int(quantity) == 0:
                                                  boxitem.enabled = False
                                              else:
                                                  boxitem.quantity = int(quantity)
                  Severity: Major
                  Found in chezbetty/views_admin.py - About 45 mins to fix

                    Function admin_cash_adjustment_submit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def admin_cash_adjustment_submit(request):
                        try:
                            amount = Decimal(request.POST['amount'])
                    
                            # Look for custom date
                    Severity: Minor
                    Found in chezbetty/views_admin.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 admin_cash_donation_submit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def admin_cash_donation_submit(request):
                        try:
                            amount = Decimal(request.POST['amount'])
                    
                            # Look for custom date
                    Severity: Minor
                    Found in chezbetty/views_admin.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 admin_users_archive_old_submit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def admin_users_archive_old_submit(request):
                        count = 0
                        users = User.get_normal_users()
                        for user in users:
                            if user.days_since_last_purchase is not None and user.days_since_last_purchase >= 180:
                    Severity: Minor
                    Found in chezbetty/views_admin.py - About 35 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 admin_event has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def admin_event(request):
                        try:
                            event = Event.from_id(int(request.matchdict['event_id']))
                    
                            # Mangers can only see restocks.
                    Severity: Minor
                    Found in chezbetty/views_admin.py - About 35 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 admin_pool_addmember_submit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def admin_pool_addmember_submit(request):
                        try:
                            pool = Pool.from_id(request.POST['pool-id'])
                    
                            # Look up the user that is being added to the pool
                    Severity: Minor
                    Found in chezbetty/views_admin.py - About 35 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

                    Avoid too many return statements within this function.
                    Open

                            return HTTPFound(location=request.route_url('admin_user_balance_edit'))
                    Severity: Major
                    Found in chezbetty/views_admin.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return {'status': 'error'}
                      Severity: Major
                      Found in chezbetty/views_admin.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return HTTPFound(location=request.route_url('admin_cash_reconcile'))
                        Severity: Major
                        Found in chezbetty/views_admin.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return HTTPFound(location=request.route_url('admin_events'))
                          Severity: Major
                          Found in chezbetty/views_admin.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return HTTPFound(location=request.route_url('admin_events'))
                            Severity: Major
                            Found in chezbetty/views_admin.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return HTTPFound(location=request.route_url('admin_user_purchase_add'))
                              Severity: Major
                              Found in chezbetty/views_admin.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return HTTPFound(location=request.route_url('admin_box_edit', box_id=int(request.POST['box-id'])))
                                Severity: Major
                                Found in chezbetty/views_admin.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                  return HTTPFound(location=request.route_url('admin_event', event_id=event.id))
                                  Severity: Major
                                  Found in chezbetty/views_admin.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return HTTPFound(location=request.route_url('admin_events'))
                                    Severity: Major
                                    Found in chezbetty/views_admin.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return HTTPFound(location=request.route_url('admin_user_balance_edit'))
                                      Severity: Major
                                      Found in chezbetty/views_admin.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                    return HTTPFound(location=request.route_url('admin_events'))
                                        Severity: Major
                                        Found in chezbetty/views_admin.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                  return HTTPFound(location=request.route_url('admin_reimbursees'))
                                          Severity: Major
                                          Found in chezbetty/views_admin.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return HTTPFound(location=request.route_url('admin_user_balance_edit'))
                                            Severity: Major
                                            Found in chezbetty/views_admin.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return HTTPFound(location=request.route_url('admin_cash_reconcile'))
                                              Severity: Major
                                              Found in chezbetty/views_admin.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return HTTPFound(location=request.route_url('admin_item_edit', item_id=int(request.POST['item-id'])))
                                                Severity: Major
                                                Found in chezbetty/views_admin.py - About 30 mins to fix

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

                                                  def admin_user_archive(request):
                                                      try:
                                                          user = User.from_id(int(request.matchdict['user_id']))
                                                  
                                                          # Cannot archive already archived user
                                                  Severity: Minor
                                                  Found in chezbetty/views_admin.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 admin_inventory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                  def admin_inventory(request):
                                                      items1 = DBSession.query(Item)\
                                                                        .filter(Item.enabled==True)\
                                                                        .filter(Item.in_stock!=0)\
                                                                        .order_by(Item.name).all()
                                                  Severity: Minor
                                                  Found in chezbetty/views_admin.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 admin_index_history_semesters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                  def admin_index_history_semesters(request):
                                                      semester = request.matchdict['semester']
                                                  
                                                      year_start = 2014
                                                      year_end = arrow.now().year
                                                  Severity: Minor
                                                  Found in chezbetty/views_admin.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_event_filter_function has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                  def _get_event_filter_function(event_filter):
                                                      fields = event_filter.split(':')
                                                      if fields[0] == 'type':
                                                          def filterfn (*args, **kwargs):
                                                              return Event.get_events_by_type(fields[1], *args, **kwargs)
                                                  Severity: Minor
                                                  Found in chezbetty/views_admin.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

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status