hackedteam/vector-edk

View on GitHub
BaseTools/Source/Python/Trim/Trim.py

Summary

Maintainability
F
4 days
Test Coverage

Function TrimPreprocessedFile has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
    CreateDirectory(os.path.dirname(Target))
    try:
        f = open (Source, 'r')
    except:
Severity: Minor
Found in BaseTools/Source/Python/Trim/Trim.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

File Trim.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

## @file
# Trim files preprocessed by compiler
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
Severity: Minor
Found in BaseTools/Source/Python/Trim/Trim.py - About 4 hrs to fix

    Function TrimPreprocessedVfr has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def TrimPreprocessedVfr(Source, Target):
        CreateDirectory(os.path.dirname(Target))
        
        try:
            f = open (Source,'r')
    Severity: Minor
    Found in BaseTools/Source/Python/Trim/Trim.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 TrimEdkSources has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def TrimEdkSources(Source, Target):
        if os.path.isdir(Source):
            for CurrentDir, Dirs, Files in os.walk(Source):
                if '.svn' in Dirs:
                    Dirs.remove('.svn')
    Severity: Minor
    Found in BaseTools/Source/Python/Trim/Trim.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 DoInclude has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def DoInclude(Source, Indent='', IncludePathList=[], LocalSearchPath=None):
        NewFileContent = []
    
        try:
            #
    Severity: Minor
    Found in BaseTools/Source/Python/Trim/Trim.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 Main has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def Main():
        try:
            EdkLogger.Initialize()
            CommandOptions, InputFile = Options()
            if CommandOptions.LogLevel < EdkLogger.DEBUG_9:
    Severity: Minor
    Found in BaseTools/Source/Python/Trim/Trim.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 TrimAslFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def TrimAslFile(Source, Target, IncludePathFile):
        CreateDirectory(os.path.dirname(Target))
        
        SourceDir = os.path.dirname(Source)
        if SourceDir == '':
    Severity: Minor
    Found in BaseTools/Source/Python/Trim/Trim.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

    Avoid deeply nested control flow statements.
    Open

                        for LineIndex in range(len(NewLines), LineNumber-1):
                            NewLines.append(os.linesep)
                    NewLines.append(Line)
    Severity: Major
    Found in BaseTools/Source/Python/Trim/Trim.py - About 45 mins to fix

      Function TrimEdkSourceCode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def TrimEdkSourceCode(Source, Target):
          EdkLogger.verbose("\t%s -> %s" % (Source, Target))
          CreateDirectory(os.path.dirname(Target))
      
          try:
      Severity: Minor
      Found in BaseTools/Source/Python/Trim/Trim.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

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

      if __name__ == '__main__':
          r = Main()
          ## 0-127 is a safe return range, and 1 is a standard default error
          if r < 0 or r > 127: r = 1
          sys.exit(r)
      Severity: Major
      Found in BaseTools/Source/Python/Trim/Trim.py and 4 other locations - About 2 hrs to fix
      BaseTools/Source/Python/BPDG/BPDG.py on lines 153..157
      BaseTools/Source/Python/GenFds/GenFds.py on lines 533..537
      BaseTools/Source/Python/UPT/UPT.py on lines 232..239
      BaseTools/Source/Python/build/build.py on lines 1901..1905

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

      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

              if CommandOptions.LogLevel < EdkLogger.DEBUG_9:
                  EdkLogger.SetLevel(CommandOptions.LogLevel + 1)
              else:
                  EdkLogger.SetLevel(CommandOptions.LogLevel)
      Severity: Major
      Found in BaseTools/Source/Python/Trim/Trim.py and 1 other location - About 1 hr to fix
      BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py on lines 261..264

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

      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 CommandOptions.OutputFile == None:
                      CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
      Severity: Major
      Found in BaseTools/Source/Python/Trim/Trim.py and 2 other locations - About 1 hr to fix
      BaseTools/Source/Python/Trim/Trim.py on lines 570..571
      BaseTools/Source/Python/Trim/Trim.py on lines 580..581

      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 CommandOptions.OutputFile == None:
                      CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
      Severity: Major
      Found in BaseTools/Source/Python/Trim/Trim.py and 2 other locations - About 1 hr to fix
      BaseTools/Source/Python/Trim/Trim.py on lines 570..571
      BaseTools/Source/Python/Trim/Trim.py on lines 574..575

      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 CommandOptions.OutputFile == None:
                      CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'
      Severity: Major
      Found in BaseTools/Source/Python/Trim/Trim.py and 2 other locations - About 1 hr to fix
      BaseTools/Source/Python/Trim/Trim.py on lines 574..575
      BaseTools/Source/Python/Trim/Trim.py on lines 580..581

      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

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

          if len(Args) == 0:
              EdkLogger.error("Trim", OPTION_MISSING, ExtraData=Parser.get_usage())
      Severity: Minor
      Found in BaseTools/Source/Python/Trim/Trim.py and 1 other location - About 30 mins to fix
      BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py on lines 239..240

      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