um-cseg/chez-betty

View on GitHub
chezbetty/models/transaction.py

Summary

Maintainability
F
3 days
Test Coverage

File transaction.py has 851 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from .model import *
from . import account
from . import event
from . import item
from . import box
Severity: Major
Found in chezbetty/models/transaction.py - About 2 days to fix

    Function datefilter_one_or_zero has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    def datefilter_one_or_zero(label=None):
        def wrap(fn_being_decorated):
            @functools.wraps(fn_being_decorated)
            def wrapped_fn(*args,
                    start=None, end=None,
    Severity: Minor
    Found in chezbetty/models/transaction.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 wrapped_fn has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def wrapped_fn(*args,
    Severity: Major
    Found in chezbetty/models/transaction.py - About 1 hr to fix

      Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,
      Severity: Major
      Found in chezbetty/models/transaction.py - About 1 hr to fix

        Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self,
        Severity: Major
        Found in chezbetty/models/transaction.py - About 1 hr to fix

          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, transaction, amount, item, quantity_predicted, quantity_counted, wholesale):
          Severity: Minor
          Found in chezbetty/models/transaction.py - About 45 mins to fix

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

                def __init__(self, event, fr_acct_virt, to_acct_virt, fr_acct_cash, to_acct_cash, amount):
                    self.to_account_virt_id = to_acct_virt.id if to_acct_virt else None
                    self.fr_account_virt_id = fr_acct_virt.id if fr_acct_virt else None
                    self.to_account_cash_id = to_acct_cash.id if to_acct_cash else None
                    self.fr_account_cash_id = fr_acct_cash.id if fr_acct_cash else None
            Severity: Minor
            Found in chezbetty/models/transaction.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 update_amount has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def update_amount(self, amount):
                    # Remove the balance we added before (upon init or last update_amount)
                    if self.to_acct_virt:
                        self.to_acct_virt.balance -= self.amount
                    if self.fr_acct_virt:
            Severity: Minor
            Found in chezbetty/models/transaction.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, event, user, amount, btctransaction, address, amount_btc):
            Severity: Minor
            Found in chezbetty/models/transaction.py - About 45 mins to fix

              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, transaction, amount, item, quantity, price, wholesale):
              Severity: Minor
              Found in chezbetty/models/transaction.py - About 45 mins to fix

                Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(self, event, fr_acct_virt, to_acct_virt, fr_acct_cash, to_acct_cash, amount):
                Severity: Minor
                Found in chezbetty/models/transaction.py - About 45 mins to fix

                  Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self, transaction, amount, item_id, quantity, wholesale):
                  Severity: Minor
                  Found in chezbetty/models/transaction.py - About 35 mins to fix

                    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(self, event, user, amount, stripe_id, last4):
                    Severity: Minor
                    Found in chezbetty/models/transaction.py - About 35 mins to fix

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

                      def __get_events_by_type(cls, event_type):
                          q = DBSession.query(event.Event)\
                                  .join(Transaction)
                      
                          if event_type == 'cash':
                      Severity: Minor
                      Found in chezbetty/models/transaction.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def __init__(self, event, user, amount):
                              cashbox_c = account.get_cash_account("cashbox")
                              prev = cashbox_c.balance
                              Transaction.__init__(self, event, None, user, None, cashbox_c, amount)
                              new = cashbox_c.balance
                      Severity: Minor
                      Found in chezbetty/models/transaction.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