hackedteam/vector-edk

View on GitHub
BaseTools/Source/Python/UPT/Parser/InfSectionParser.py

Summary

Maintainability
F
4 days
Test Coverage

Function SectionHeaderParser has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    def SectionHeaderParser(self, SectionString, FileName, LineNo):
        _Scope = []
        _SectionName = ''
        ArchList = set()
        _ValueList = []
Severity: Minor
Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.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

Function InfSpecialCommentParser has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def InfSpecialCommentParser (self, SpecialSectionList, InfSectionObject, ContainerFile, SectionType):
        ReFindSpecialCommentRe = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
        ReFindHobArchRe = re.compile(r"""[Hh][Oo][Bb]\.([^,]*)""", re.DOTALL)
        if self.FileName:
            pass
Severity: Minor
Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py - About 6 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 InfSectionParser.py has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

## @file
# This file contained the parser for sections in INF file 
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
#
Severity: Minor
Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py - About 3 hrs to fix

    Function GetSpecialStr2 has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def GetSpecialStr2(ItemList, FileName, LineNo, SectionString):
        Str2 = ''
        #
        # S2 may be Platform or ModuleType
        #
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.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 ProcessUseExtHeader has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def ProcessUseExtHeader(ItemList):
        NewItemList = []
        AppendContent = ''
        CompleteFlag = False
        for Item in ItemList:
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.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 __init__ has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self):
            InfDefinSectionParser.__init__(self)
            InfBuildOptionSectionParser.__init__(self)
            InfSourceSectionParser.__init__(self)
            InfLibrarySectionParser.__init__(self)
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                              if len(ArchList) >= 1:
                                  SpecialObject.SetSupArchList(ArchList)
                          else:
      Severity: Major
      Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if Item.strip() not in DT.MODULE_LIST:
                                    Logger.Error('Parser',
                                                 FORMAT_INVALID,
                                                 ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID % (Item),
                                                 File=FileName,
        Severity: Major
        Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py - About 45 mins to fix

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

          def GetArch(ItemList, ArchList, FileName, LineNo, SectionString):
          Severity: Minor
          Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py - About 35 mins to fix

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

                    if not (ItemList[0].upper() == DT.TAB_LIBRARY_CLASSES.upper() or \
                            ItemList[0].upper() == DT.TAB_DEPEX.upper() or \
                            ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper()):
            Severity: Major
            Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py and 1 other location - About 3 hrs to fix
            BaseTools/Source/Python/UPT/Parser/InfPcdSectionParser.py on lines 56..58

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

            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 ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper() or ItemList[0].upper() == DT.TAB_DEPEX.upper():
                        if ItemList[3] != '':
                            Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SOURCE_SECTION_SECTIONNAME_INVALID \
            Severity: Major
            Found in BaseTools/Source/Python/UPT/Parser/InfSectionParser.py and 1 other location - About 1 hr to fix
            BaseTools/Source/Python/UPT/Parser/InfSectionParser.py on lines 77..83

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

            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