hackedteam/vector-edk

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

Summary

Maintainability
F
1 mo
Test Coverage

File ihooks.py has 443 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Import hook support.

Consistent use of this module will make it possible to change the
different mechanisms involved in loading modules independently.
Severity: Minor
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.py - About 6 hrs to fix

    Function determine_parent has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def determine_parent(self, globals, level=-1):
            if not globals or not level:
                return None
            pkgname = globals.get('__package__')
            if pkgname is not None:
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.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

    Hooks has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Hooks(_Verbose):
    
        """Hooks into the filesystem and interpreter.
    
        By deriving a subclass you can redefine your filesystem interface,
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.py - About 2 hrs to fix

      Function ensure_fromlist has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def ensure_fromlist(self, m, fromlist, recursive=0):
              for sub in fromlist:
                  if sub == "*":
                      if not recursive:
                          try:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.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 load_module has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_module(self, name, stuff):
              file, filename, (suff, mode, type) = stuff
              realfilename = filename
              path = None
      
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.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 find_module_in_dir has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_module_in_dir(self, name, dir, allow_packages=1):
              if dir is None:
                  return self.find_builtin_module(name)
              if allow_packages:
                  fullname = self.hooks.path_join(dir, name)
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.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_module has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_module(self, name, stuff):
              file, filename, info = stuff
              (suff, mode, type) = info
              try:
                  if type == BUILTIN_MODULE:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.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 find_head_package has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_head_package(self, parent, name):
              if '.' in name:
                  i = name.find('.')
                  head = name[:i]
                  tail = name[i+1:]
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.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 import_module has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def import_module(self, name, globals=None, locals=None, fromlist=None,
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.py - About 35 mins to fix

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

            def import_it(self, partname, fqname, parent, force_load=0):
                if not partname:
                    # completely empty module name should only happen in
                    # 'from . import' or __import__("")
                    return parent
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.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 m
        Severity: Major
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/ihooks.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

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

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

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

            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 3295.

            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