hackedteam/vector-edk

View on GitHub
BaseTools/Source/Python/UPT/Xml/IniToXml.py

Summary

Maintainability
F
3 days
Test Coverage

Function IniToXml has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

def IniToXml(IniFile):
    if not os.path.exists(IniFile):
        Logger.Error("UPT", FILE_NOT_FOUND, ST.ERR_TEMPLATE_NOTFOUND % IniFile)

    DistMap = {'ReadOnly' : '', 'RePackage' : '', 'Name' : '',
Severity: Minor
Found in BaseTools/Source/Python/UPT/Xml/IniToXml.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 IniToXml.py has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

## @file
# This file is for converting package information data file to xml file.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
#
Severity: Minor
Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py - About 3 hrs to fix

    Function ParseFileList has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def ParseFileList(Line, Map, CurrentKey, PathFunc):
        FileList = ["", {}]
        TokenList = Line.split(TAB_VALUE_SPLIT)
        if len(TokenList) > 0:
            Path = TokenList[0].strip().replace('\\', '/')
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Xml/IniToXml.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 CheckMdtKeys has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):    
        MdtDistKeys = ['Name', 'GUID', 'Version', 'Vendor', 'Copyright', 'License', 'Abstract', 'XmlSpecification']
        for Key in MdtDistKeys:
            if Key not in DistMap or DistMap[Key] == '':
                IniParseError(ST.ERR_KEYWORD_MANDATORY % Key, IniFile, LastIndex+1)
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Xml/IniToXml.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 ValidateValues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def ValidateValues(Key, Value, SectionName):
        if SectionName == 'DistributionHeader':
            Valid, Cause = ValidateRegValues(Key, Value)
            if not Valid:
                return Valid, Cause
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Xml/IniToXml.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 CreateToolsXml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def CreateToolsXml(Map, Root, Tag):
        #
        # Check if all elements in this section are empty
        #
        for Key in Map:
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Xml/IniToXml.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 False, ST.ERR_FILELIST_ATTR % 'Executable'
    Severity: Major
    Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return False, ST.ERR_FILELIST_ATTR % 'OS'
      Severity: Major
      Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return True, ''
        Severity: Major
        Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py - About 30 mins to fix

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

          def __ValidateDistHeaderBaseName(BaseName):
              if not BaseName:
                  return False
          #    if CheckLen and len(BaseName) < 2:
          #        return False
          Severity: Minor
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.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

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

                  if NonEmptyKey > 0 and not Map['FileList']:
                      IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.FileList'), IniFile, LastIndex+1)
          Severity: Major
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py and 1 other location - About 2 hrs to fix
          BaseTools/Source/Python/UPT/Xml/IniToXml.py on lines 472..473

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

          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 NonEmptyKey > 0 and not Map['Name']:
                      IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.Name'), IniFile, LastIndex+1)
          Severity: Major
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py and 1 other location - About 2 hrs to fix
          BaseTools/Source/Python/UPT/Xml/IniToXml.py on lines 469..470

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

          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 not Valid and 'WORKSPACE' in os.environ:
                  Valid, Cause = __ValidatePath(Filename, os.environ['WORKSPACE'])
          Severity: Major
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py and 1 other location - About 1 hr to fix
          BaseTools/Source/Python/UPT/Xml/IniToXml.py on lines 72..73

          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

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

              if not Valid and 'EDK_TOOLS_PATH' in os.environ:
                  Valid, Cause = __ValidatePath(Filename, os.environ['EDK_TOOLS_PATH'])
          Severity: Major
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py and 1 other location - About 1 hr to fix
          BaseTools/Source/Python/UPT/Xml/IniToXml.py on lines 74..75

          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

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

              DistMap = {'ReadOnly' : '', 'RePackage' : '', 'Name' : '',
                         'BaseName' : '', 'GUID' : '', 'Version' : '', 'Vendor' : '',
                         'Date' : '', 'Copyright' : '', 'License' : '', 'Abstract' : '',
                         'Description' : '', 'Signature' : '', 'XmlSpecification' : ''
          Severity: Minor
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py and 1 other location - About 45 mins to fix
          BaseTools/Source/Python/UPT/Library/DataType.py on lines 87..101

          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

              return not (Value and Key in ValidateMap and not ValidateMap[Key](Value))
          Severity: Minor
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py and 1 other location - About 35 mins to fix
          BaseTools/Source/Python/UPT/Xml/IniToXml.py on lines 289..289

          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

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

              return not (Value and Key in ValidateMap and not ValidateMap[Key](Value))
          Severity: Minor
          Found in BaseTools/Source/Python/UPT/Xml/IniToXml.py and 1 other location - About 35 mins to fix
          BaseTools/Source/Python/UPT/Xml/IniToXml.py on lines 277..277

          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