hackedteam/vector-edk

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

Summary

Maintainability
F
2 mos
Test Coverage

File inspect.py has 861 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: iso-8859-1 -*-
"""Get useful information from live Python objects.

This module encapsulates the interface provided by the internal special
attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion.
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 2 days to fix

    Function getcallargs has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

    def getcallargs(func, *positional, **named):
        """Get the mapping of arguments to values.
    
        A dict is returned, with keys the function argument names (including the
        names of the * and ** arguments, if any), and values the respective bound
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 getargs has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

    def getargs(co):
        """Get information about the arguments accepted by a code object.
    
        Three things are returned: (args, varargs, varkw), where 'args' is
        a list of argument names (possibly containing nested lists), and
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 getcomments has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    def getcomments(object):
        """Get lines of comments immediately preceding an object's source code.
    
        Returns None when source can't be found.
        """
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 findsource has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def findsource(object):
        """Return the entire source file and starting line number for an object.
    
        The argument may be a module, class, method, function, traceback, frame,
        or code object.  The source code is returned as a list of all the lines
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 classify_class_attrs has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def classify_class_attrs(cls):
        """Return list of attribute-descriptor tuples.
    
        For each name in dir(cls), the return list contains a 4-tuple
        with these elements:
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 getmodule has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def getmodule(object, _filename=None):
        """Return the module an object was defined in, or None if not found."""
        if ismodule(object):
            return object
        if hasattr(object, '__module__'):
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 getclasstree has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def getclasstree(classes, unique=0):
        """Arrange the given list of classes into a hierarchy of nested lists.
    
        Where a nested list appears, it contains classes derived from the class
        whose entry immediately precedes the list.  Each entry is a 2-tuple
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 tokeneater has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def tokeneater(self, type, token, srow_scol, erow_ecol, line):
            srow, scol = srow_scol
            erow, ecol = erow_ecol
            if not self.started:
                # look for the first "def", "class" or "lambda"
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 cleandoc has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def cleandoc(doc):
        """Clean up indentation from docstrings.
    
        Any whitespace that can be uniformly removed from the second line
        onwards is removed."""
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 getfile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def getfile(object):
        """Work out which source or compiled file an object was defined in."""
        if ismodule(object):
            if hasattr(object, '__file__'):
                return object.__file__
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 formatargspec has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def formatargspec(args, varargs=None, varkw=None, defaults=None,
    Severity: Major
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 1 hr to fix

      Function formatargvalues has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def formatargvalues(args, varargs, varkw, locals,
      Severity: Major
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 1 hr to fix

        Function getframeinfo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def getframeinfo(frame, context=1):
            """Get information about a frame or traceback object.
        
            A tuple of five things is returned: the filename, the line number of
            the current line, the function name, a list of lines of context from
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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

        Avoid deeply nested control flow statements.
        Open

                            if end < 0: break
                            comment = string.lstrip(string.expandtabs(lines[end]))
        Severity: Major
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'):
                                  remain.append(value)
                                  count.append(value)
                              elif opname == 'STORE_FAST':
                                  stack.append(names[value])
          Severity: Major
          Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 45 mins to fix

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

                def tokeneater(self, type, token, srow_scol, erow_ecol, line):
            Severity: Minor
            Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 35 mins to fix

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

              def getsourcefile(object):
                  """Return the filename that can be used to locate an object's source.
                  Return None if no way can be identified to get the source.
                  """
                  filename = getfile(object)
              Severity: Minor
              Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 None
              Severity: Major
              Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return sys.modules.get(modulesbyfile[file])
                Severity: Major
                Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return sys.modules.get(modulesbyfile[file])
                  Severity: Major
                  Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return main
                    Severity: Major
                    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return builtin
                      Severity: Major
                      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py - About 30 mins to fix

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

                        def getmembers(object, predicate=None):
                            """Return all members of an object as (name, value) pairs sorted by name.
                            Optionally, only return members that satisfy a given predicate."""
                            results = []
                            for key in dir(object):
                        Severity: Minor
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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 formatargspec has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def formatargspec(args, varargs=None, varkw=None, defaults=None,
                                          formatarg=str,
                                          formatvarargs=lambda name: '*' + name,
                                          formatvarkw=lambda name: '**' + name,
                                          formatvalue=lambda value: '=' + repr(value),
                        Severity: Minor
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.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

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                        Severity: Major
                        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/inspect.py and 1 other location - About 2 mos to fix
                        vector-uefi/fd/efi/StdLib/lib/python.27/inspect.py on lines 0..1056

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 6444.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        There are no issues that match your filters.

                        Category
                        Status