Shoobx/pjpersist

View on GitHub
src/pjpersist/datamanager.py

Summary

Maintainability
F
3 days
Test Coverage

File datamanager.py has 675 lines of code (exceeds 250 allowed). Consider refactoring.
Open

##############################################################################
#
# Copyright (c) 2011 Zope Foundation and Contributors.
# Copyright (c) 2014 Shoobx, Inc.
# All Rights Reserved.
Severity: Major
Found in src/pjpersist/datamanager.py - About 1 day to fix

    PJDataManager has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PJDataManager(object):
    
        root = None
    
        # Data manager is completely new. NOTE: It is important to leave this
    Severity: Minor
    Found in src/pjpersist/datamanager.py - About 5 hrs to fix

      Function flush has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def flush(self, flush_hint=None):
              # flush_hint contains tables that we want to flush, leaving all other
              # objects registered.
              #
              # While writing objects, new sub-objects might be registered
      Severity: Minor
      Found in src/pjpersist/datamanager.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 register has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def register(self, obj):
              self._join_txn()
      
              if self._readonly:
                  raise interfaces.ReadOnlyDataManagerError()
      Severity: Minor
      Found in src/pjpersist/datamanager.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 _execute_and_log has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _execute_and_log(self, sql, args):
              # Very useful logging of every SQL command with traceback to code.
              __traceback_info__ = (self.datamanager.database, sql, args)
              started = time.time()
              try:
      Severity: Minor
      Found in src/pjpersist/datamanager.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute(self, sql, args=None, beacon=None, flush_hint=None):
              """execute a SQL statement
              sql - SQL string or SQLBuilder expression
              args - optional list of args for the SQL string
              beacon - optional unique identifier for the statement to help
      Severity: Minor
      Found in src/pjpersist/datamanager.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_doc has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _update_doc(self, database, table, doc, id, column_data=None):
      Severity: Minor
      Found in src/pjpersist/datamanager.py - About 35 mins to fix

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

            def _insert_doc(self, database, table, doc, id=None, column_data=None):
        Severity: Minor
        Found in src/pjpersist/datamanager.py - About 35 mins to fix

          Function tpc_vote has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def tpc_vote(self, transaction):
                  if self._tpc_activated:
                      assert self._conn.status == psycopg2.extensions.STATUS_BEGIN
                      if self.isDirty():
                          # if the transaction wrote anything we have to call tpc_prepare
          Severity: Minor
          Found in src/pjpersist/datamanager.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 remove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def remove(self, obj):
                  if obj._p_oid is None:
                      raise ValueError('Object._p_oid is None.', obj)
                  # If the object is still in the ghost state, let's load it, so that we
                  # have the state in case we abort the transaction later.
          Severity: Minor
          Found in src/pjpersist/datamanager.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 _ensure_sql_columns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _ensure_sql_columns(self, obj, table):
                  # create the table required for the object, with the necessary
                  # _pj_column_fields translated to SQL types
                  if PJ_AUTO_CREATE_COLUMNS:
                      if interfaces.IColumnSerialization.providedBy(obj):
          Severity: Minor
          Found in src/pjpersist/datamanager.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 _autoCreateTables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _autoCreateTables(self, sql, args, beacon):
                  # XXX: need to set a savepoint, just in case the real execute
                  #      fails, it would take down all further commands
                  super(PJPersistCursor, self).execute("SAVEPOINT before_execute;")
          
          
          Severity: Minor
          Found in src/pjpersist/datamanager.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