hackedteam/vector-edk

View on GitHub
BaseTools/Source/Python/AutoGen/GenDepex.py

Summary

Maintainability
F
4 days
Test Coverage

Function GetPostfixNotation has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

    def GetPostfixNotation(self):
        Stack = []
        LastToken = ''
        for Token in self.TokenList:
            if Token == "(":
Severity: Minor
Found in BaseTools/Source/Python/AutoGen/GenDepex.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

File GenDepex.py has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

## @file
# This file is used to generate DEPEX file for module's dependency expression
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
Severity: Minor
Found in BaseTools/Source/Python/AutoGen/GenDepex.py - About 3 hrs to fix

    Function Optimize has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def Optimize(self):
            ValidOpcode = list(set(self.OpcodeList))
            if len(ValidOpcode) != 1 or ValidOpcode[0] not in ['AND', 'OR']:
                return
            Op = ValidOpcode[0]
    Severity: Minor
    Found in BaseTools/Source/Python/AutoGen/GenDepex.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 Main has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def Main():
        EdkLogger.Initialize()
        Option, Input = GetOptions()
    
        # Set log level
    Severity: Minor
    Found in BaseTools/Source/Python/AutoGen/GenDepex.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 ValidateOpcode has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def ValidateOpcode(self):
            for Op in self.AboveAllOpcode:
                if Op in self.PostfixNotation:
                    if Op != self.PostfixNotation[0]:
                        EdkLogger.error("GenDepex", PARSER_ERROR, "%s should be the first opcode in the expression" % Op,
    Severity: Minor
    Found in BaseTools/Source/Python/AutoGen/GenDepex.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 Generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def Generate(self, File=None):
            Buffer = StringIO()
            if len(self.PostfixNotation) == 0:
                return False
    
    Severity: Minor
    Found in BaseTools/Source/Python/AutoGen/GenDepex.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

    Avoid deeply nested control flow statements.
    Open

                            if Token not in self.SupportedOperand:
                                self.PostfixNotation.append("PUSH")
                    # check if OP is valid in this phase
                    elif Token in self.Opcode[self.Phase]:
    Severity: Major
    Found in BaseTools/Source/Python/AutoGen/GenDepex.py - About 45 mins to fix

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

          if Option.quiet:
              EdkLogger.SetLevel(EdkLogger.QUIET)
          elif Option.verbose:
              EdkLogger.SetLevel(EdkLogger.VERBOSE)
          elif Option.debug != None:
      Severity: Major
      Found in BaseTools/Source/Python/AutoGen/GenDepex.py and 1 other location - About 4 hrs to fix
      BaseTools/Source/Python/BPDG/BPDG.py on lines 56..63

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

      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 Token == "NOT":
                          if LastToken not in self.SupportedOpcode + ['(', '', None]:
                              EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator before NOT",
                                              ExtraData="Near %s" % LastToken)
      Severity: Major
      Found in BaseTools/Source/Python/AutoGen/GenDepex.py and 1 other location - About 1 hr to fix
      BaseTools/Source/Python/AutoGen/GenDepex.py on lines 171..173

      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

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

                      if LastToken not in self.SupportedOpcode + ['(', '', None]:
                          EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid dependency expression: missing operator before open parentheses",
                                          ExtraData="Near %s" % LastToken)
      Severity: Major
      Found in BaseTools/Source/Python/AutoGen/GenDepex.py and 1 other location - About 1 hr to fix
      BaseTools/Source/Python/AutoGen/GenDepex.py on lines 188..191

      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 2 locations. Consider refactoring.
      Open

                      if len(self.PostfixNotation) < 3:
                          EdkLogger.error("GenDepex", PARSER_ERROR, "Missing operand for %s" % Op,
                                          ExtraData=str(self))
      Severity: Major
      Found in BaseTools/Source/Python/AutoGen/GenDepex.py and 1 other location - About 1 hr to fix
      BaseTools/Source/Python/AutoGen/GenDepex.py on lines 239..241

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

      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 len(self.PostfixNotation) < 3:
                          EdkLogger.error("GenDepex", PARSER_ERROR, "Missing operand for %s" % Op,
                                          ExtraData=str(self))
      Severity: Major
      Found in BaseTools/Source/Python/AutoGen/GenDepex.py and 1 other location - About 1 hr to fix
      BaseTools/Source/Python/AutoGen/GenDepex.py on lines 247..249

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

      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 self.TokenList[-1] == 'END' and self.TokenList[-2] in self.NonEndingOpcode:
                  EdkLogger.error("GenDepex", PARSER_ERROR, "Extra %s at the end of the dependency expression" % self.TokenList[-2],
                                  ExtraData=str(self))
      Severity: Minor
      Found in BaseTools/Source/Python/AutoGen/GenDepex.py and 1 other location - About 35 mins to fix
      BaseTools/Source/Python/AutoGen/GenDepex.py on lines 250..252

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

      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 self.TokenList[-1] != 'END' and self.TokenList[-1] in self.NonEndingOpcode:
                  EdkLogger.error("GenDepex", PARSER_ERROR, "Extra %s at the end of the dependency expression" % self.TokenList[-1],
                                  ExtraData=str(self))
      Severity: Minor
      Found in BaseTools/Source/Python/AutoGen/GenDepex.py and 1 other location - About 35 mins to fix
      BaseTools/Source/Python/AutoGen/GenDepex.py on lines 253..255

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

      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