hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.py

Summary

Maintainability
F
6 days
Test Coverage

File pickle.py has 1023 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Create portable serialized representations of Python objects.

See module cPickle for a (much) faster implementation.
See module copy_reg for a mechanism for registering custom picklers.
See module pickletools source for extensive comments.
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.py - About 2 days to fix

    Unpickler has 60 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Unpickler:
    
        def __init__(self, file):
            """This takes a file-like object for reading a pickle data stream.
    
    Severity: Major
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.py - About 1 day to fix

      Pickler has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Pickler:
      
          def __init__(self, file, protocol=None):
              """This takes a file-like object for writing a pickle data stream.
      
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.py - About 3 hrs to fix

        Function save_string has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

                def save_string(self, obj, pack=struct.pack):
                    unicode = obj.isunicode()
        
                    if self.bin:
                        if unicode:
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 save has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def save(self, obj):
                # Check for persistent id (defined by a subclass)
                pid = self.persistent_id(obj)
                if pid:
                    self.save_pers(pid)
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 _batch_setitems has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def _batch_setitems(self, items):
                # Helper to batch up SETITEMS sequences; proto >= 1 only
                save = self.save
                write = self.write
        
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 _batch_appends has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def _batch_appends(self, items):
                # Helper to batch up APPENDS sequences
                save = self.save
                write = self.write
        
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 load_build has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_build(self):
                stack = self.stack
                state = stack.pop()
                inst = stack[-1]
                setstate = getattr(inst, "__setstate__", None)
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 save_tuple has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def save_tuple(self, obj):
                write = self.write
                proto = self.proto
        
                n = len(obj)
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 encode_long has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def encode_long(x):
            r"""Encode a long to a two's complement little-endian binary string.
            Note that 0L is a special case, returning an empty string, to save a
            byte in the LONG1 pickling context.
        
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 save_reduce has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def save_reduce(self, func, args, state=None,
                            listitems=None, dictitems=None, obj=None):
                # This API is called by some subclasses
        
                # Assert that args is a tuple or None
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 save_global has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def save_global(self, obj, name=None, pack=struct.pack):
                write = self.write
                memo = self.memo
        
                if name is None:
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 save_int has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def save_int(self, obj, pack=struct.pack):
                if self.bin:
                    # If the int is small enough to fit in a signed 4-byte 2's-comp
                    # format, we can store it more efficiently than the general
                    # case.
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 save_inst has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def save_inst(self, obj):
                cls = obj.__class__
        
                memo  = self.memo
                write = self.write
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 whichmodule has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def whichmodule(func, funcname):
            """Figure out the module in which a function occurs.
        
            Search sys.modules for the module.
            Cache in classmap.
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 save_reduce has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def save_reduce(self, func, args, state=None,
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.py - About 45 mins to fix

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

              def load_string(self):
                  rep = self.readline()[:-1]
                  for q in "\"'": # double or single quote
                      if rep.startswith(q):
                          if not rep.endswith(q):
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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 _instantiate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _instantiate(self, klass, k):
                  args = tuple(self.stack[k+1:])
                  del self.stack[k:]
                  instantiated = 0
                  if (not args and
          Severity: Minor
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.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
          Severity: Major
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/pickle.py - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status