hackedteam/vector-edk

View on GitHub
BaseTools/Source/Python/Workspace/WorkspaceCommon.py

Summary

Maintainability
F
6 days
Test Coverage

Function _GetModuleLibraryInstances has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
Open

def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):
    ModuleType = Module.ModuleType

    # for overriding library instances with module specific setting
    PlatformModule = Platform.Modules[str(Module)]
Severity: Minor
Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 2 days 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 _ResolveLibraryReference has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def _ResolveLibraryReference(Module, Platform):
    LibraryConsumerList = [Module]

    # "CompilerStub" is a must for Edk modules
    if Module.Libraries:
Severity: Minor
Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.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

Avoid deeply nested control flow statements.
Open

                    if LibraryName.upper() == Key.upper():
                        Library = Platform.LibraryClasses[Key, ':dummy:']
                        break
                if Library == None:
Severity: Major
Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 45 mins to fix

    Function GetLiabraryInstances has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def GetLiabraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):
    Severity: Minor
    Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 45 mins to fix

      Function _GetModuleLibraryInstances has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):
      Severity: Minor
      Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if Node in Constructor:
                                continue
                            # remove edge e from the graph if Node has no constructor
                            ConsumedByList[Item].remove(Node)
        Severity: Major
        Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if LibraryPath == None or LibraryPath == "":
                                  return []
          
          Severity: Major
          Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if ConsumedByList[Item] == []:
                                    # insert Item into Q
                                    Q.insert(0, Item)
                                    break
                            if Q != []:
            Severity: Major
            Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 45 mins to fix

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

              def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain):
              Severity: Minor
              Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 35 mins to fix

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

                def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain):
                Severity: Minor
                Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py - About 35 mins to fix

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

                      while True:
                          EdgeRemoved = True
                          while Q == [] and EdgeRemoved:
                              EdgeRemoved = False
                              # for each node Item with a Constructor
                  Severity: Major
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 1 other location - About 2 days to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 1540..1580

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

                  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

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

                                  elif LibraryModule.LibraryClass == None \
                                       or len(LibraryModule.LibraryClass) == 0 \
                                       or (ModuleType != 'USER_DEFINED'
                                           and ModuleType not in LibraryModule.LibraryClass[0].SupModList):
                  Severity: Major
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 1 other location - About 2 hrs to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 1493..1496

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

                  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

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

                      for LibraryClassName in LibraryInstance:
                          M = LibraryInstance[LibraryClassName]
                          LibraryList.append(M)
                          if ConsumedByList[M] == []:
                              Q.append(M)
                  Severity: Major
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 1 other location - About 2 hrs to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 1531..1535

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

                  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

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

                              if M != Module:
                                  if M in ConsumedByList[LibraryModule]:
                                      continue
                                  ConsumedByList[LibraryModule].append(M)
                  Severity: Major
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 2 other locations - About 1 hr to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 1518..1521
                  BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py on lines 990..993

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

                  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

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

                      for LibraryClass in PlatformModule.LibraryClasses:
                          if LibraryClass.startswith("NULL"):
                              Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]
                  Severity: Major
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 1 other location - About 1 hr to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 1460..1462

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

                  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

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

                          if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:
                  Severity: Major
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 2 other locations - About 45 mins to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 1586..1586
                  BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py on lines 1088..1088

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

                  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

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

                          for Pcd in Pkg.Pcds:
                              DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]
                  Severity: Minor
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 1 other location - About 40 mins to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 303..303

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

                  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

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

                              if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:
                                  Constructor.append(LibraryModule)
                  Severity: Minor
                  Found in BaseTools/Source/Python/Workspace/WorkspaceCommon.py and 2 other locations - About 30 mins to fix
                  BaseTools/Source/Python/AutoGen/AutoGen.py on lines 1512..1513
                  BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py on lines 985..986

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

                  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