Shoobx/pjpersist

View on GitHub

Showing 66 of 89 total issues

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

    File serialize.py has 505 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/serialize.py - About 1 day to fix

      File container.py has 465 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: Minor
      Found in src/pjpersist/zope/container.py - About 7 hrs to fix

        Function get_object has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_object(self, state, obj):
                # stateIsDict and state_py_type: optimization to avoid X lookups
                # the code was:
                # if isinstance(state, dict) and state.get('_py_type') == 'DBREF':
                # this methods gets called a gazillion times, so being fast is crucial
        Severity: Minor
        Found in src/pjpersist/serialize.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

        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 get_state has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_state(self, obj, pobj=None):
                  objectType = type(obj)
                  __traceback_info__ = obj, objectType, pobj
                  if objectType in interfaces.PJ_NATIVE_TYPES:
                      # If we have a native type, we'll just use it as the state.
          Severity: Minor
          Found in src/pjpersist/serialize.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

          PJContainer has 39 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class PJContainer(contained.Contained,
                            persistent.Persistent,
                            MutableMapping):
              _pj_table = None
              _pj_mapping_key = 'key'
          Severity: Minor
          Found in src/pjpersist/zope/container.py - About 5 hrs to fix

            Function operator_expr has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def operator_expr(self, operator, field, key, op2):
                    op1 = self.getField(field, key, json=True)
                    # some values, esp. datetime must go through PJ serialize
                    pjvalue = serialize.ObjectWriter(None).get_state(op2)
                    op2j = json.dumps(pjvalue, sort_keys=True)
            Severity: Minor
            Found in src/pjpersist/mquery.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 convert has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                def convert(self, query):
                    clauses = []
                    doc = sb.Field(self.table, self.field)
                    for key, value in sorted(query.items()):
                        accessor = self.getField(doc, key, json=True)
            Severity: Minor
            Found in src/pjpersist/mquery.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 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 _get_sb_fields has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def _get_sb_fields(self, fields):
                    """Return sqlbuilder columns for a SELECT query based on
                    passed field names or * if no fields are passed
            
                    Prefers native columns where available
            Severity: Minor
            Found in src/pjpersist/zope/container.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 resolve has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def resolve(self, dbref):
                    __traceback_info__ = dbref
                    # 1. Try to optimize on whether there's just one class stored in one
                    #    table, that can save us one DB query
                    if dbref.table in TABLE_KLASS_MAP:
            Severity: Minor
            Found in src/pjpersist/serialize.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 get_non_persistent_state has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_non_persistent_state(self, obj):
                    objectId = id(obj)
                    objectType = type(obj)
                    __traceback_info__ = obj, objectType, objectId
                    # XXX: Look at the pickle library how to properly handle all types and
            Severity: Minor
            Found in src/pjpersist/serialize.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 getField has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def getField(self, field, key, json=False):
                    if isinstance(field, sb.SQLConstant):
                        # hack for $elemMatch
                        accessor = field
                    elif key == '_id':
            Severity: Minor
            Found in src/pjpersist/mquery.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 store has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def store(self, obj, ref_only=False, id=None):
                    __traceback_info__ = (obj, ref_only)
            
                    # If it is the first time that this type of object is stored, getting
                    # the table name has the side affect of telling the class whether it
            Severity: Minor
            Found in src/pjpersist/serialize.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 simple_resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def simple_resolve(self, path):
                    path = path.replace('_dot_', '.')
                    path = path[1:] if path.startswith('u_') else path
                    # We try to look up the klass from a cache. The important part here is
                    # that we also cache lookup failures as None, since they actually
            Severity: Minor
            Found in src/pjpersist/serialize.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 __delitem__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __delitem__(self, key):
                    value = self[key]
                    # First remove the parent and name from the object.
                    if self._pj_mapping_key is not None:
                        try:
            Severity: Minor
            Found in src/pjpersist/zope/container.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, user=None, password=None, host='localhost', port=5432,
            Severity: Minor
            Found in src/pjpersist/pool.py - About 45 mins to fix

              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

              Severity
              Category
              Status
              Source
              Language