hackedteam/vector-edk

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

Summary

Maintainability
F
6 days
Test Coverage

Function ParseInfFile has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
Open

    def ParseInfFile(self, Filename):
        
        Filename = NormPath(Filename)
        (Path, Name) = os.path.split(Filename)
        self.FullPath = Filename
Severity: Minor
Found in BaseTools/Source/Python/UPT/Parser/InfParser.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 InfParser.py has 439 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function _ExtractEventHobBootMod has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        def _ExtractEventHobBootMod(self, FileLinesList):
            SpecialSectionStart = False
            CheckLocation = False
            GFindSpecialCommentRe = \
            re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/InfParser.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

    Function _CheckSectionHeaders has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def _CheckSectionHeaders(self, Line, LineNo):
            if len(self.SectionHeaderContent) == 0:
                Logger.Error("InfParser", 
                             FORMAT_INVALID,
                             ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 4 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 _CallSectionParsers has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag, 
                                SectionLines, InfSectionCommonDefObj, LineNo):
            if CurrentSection == DT.MODEL_META_DATA_DEFINE:
                if not DefineSectionParsedFlag:
                    self.InfDefineParser(SectionLines,
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/InfParser.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 ParseInfFile has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def ParseInfFile(self, Filename):
            
            Filename = NormPath(Filename)
            (Path, Name) = os.path.split(Filename)
            self.FullPath = Filename
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                              if MatchObject:
                                  CheckLocation = False
                              elif Line:
                                  Logger.Warn("Parser", 
                                               ST.WARN_SPECIAL_SECTION_LOCATION_WRONG, 
      Severity: Major
      Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not Line.startswith(DT.TAB_COMMENT_SPLIT):
                                    Logger.Warn("Parser", 
                                                 ST.WARN_SPECIAL_SECTION_LOCATION_WRONG, 
                                                 File=self.FullPath, Line=LineNum)
                                    SpecialSectionStart = False
        Severity: Major
        Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (not IsValidInfMoudleTypeList(MoudleTypeList)):
                                      Logger.Error("InfParser",
                                                   FORMAT_INVALID,
                                                   ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[2]),
                                                   File=self.FullPath, Line=LineNo,
          Severity: Major
          Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 45 mins to fix

            Consider simplifying this complex logical expression.
            Open

                        if (Line.startswith(DT.TAB_COMMENT_SPLIT) and CurrentSection == DT.MODEL_META_DATA_FILE_HEADER) and\
                            HeaderCommentStart and not Line.startswith(DT.TAB_SPECIAL_COMMENT) and not\
                            HeaderCommentEnd and NextLine != '':
                            SectionLines.append((Line, LineNo))
                            continue
            Severity: Major
            Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                          if (Line.startswith(DT.TAB_COMMENT_SPLIT) and CurrentSection == DT.MODEL_META_DATA_FILE_HEADER) and\
                              BinaryHeaderCommentStart and not Line.startswith(DT.TAB_SPECIAL_COMMENT) and not\
                              BinaryHeaderCommentEnd and NextLine != '':
                              SectionLines.append((Line, LineNo))
                              continue
              Severity: Major
              Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 40 mins to fix

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

                    def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag, 
                Severity: Minor
                Found in BaseTools/Source/Python/UPT/Parser/InfParser.py - About 35 mins to fix

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

                      def _ProcessLastSection(self, SectionLines, Line, LineNo, CurrentSection):
                          #
                          # The last line is a section header. will discard it.
                          #
                          if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):                      
                  Severity: Minor
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.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 (Line.startswith(DT.TAB_COMMENT_SPLIT) and CurrentSection == DT.MODEL_META_DATA_FILE_HEADER) and\
                                  HeaderCommentStart and not Line.startswith(DT.TAB_SPECIAL_COMMENT) and not\
                                  HeaderCommentEnd and NextLine != '':
                                  SectionLines.append((Line, LineNo))
                                  continue
                  Severity: Major
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 1 other location - About 3 hrs to fix
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 273..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 68.

                  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 (Line.startswith(DT.TAB_COMMENT_SPLIT) and CurrentSection == DT.MODEL_META_DATA_FILE_HEADER) and\
                                  BinaryHeaderCommentStart and not Line.startswith(DT.TAB_SPECIAL_COMMENT) and not\
                                  BinaryHeaderCommentEnd and NextLine != '':
                                  SectionLines.append((Line, LineNo))
                                  continue
                  Severity: Major
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 1 other location - About 3 hrs to fix
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 217..221

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

                  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 IsValidInfMoudleTypeList(MoudleTypeList)):
                                              Logger.Error("InfParser",
                                                           FORMAT_INVALID,
                                                           ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[2]),
                                                           File=self.FullPath, Line=LineNo,
                  Severity: Major
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 1 other location - About 1 hr to fix
                  BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py on lines 259..263

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

                  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 (Line == '' or not Line) and LineNo == len(FileLinesList):
                                  LastSectionFalg = True
                  Severity: Major
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 1 other location - About 1 hr to fix
                  BaseTools/Source/Python/Ecc/Check.py on lines 435..436

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

                          if len(self.EventList) >= 1:
                              self.InfSpecialCommentParser(self.EventList, 
                                                           self.InfSpecialCommentSection,
                                                           self.FileName, 
                                                           DT.TYPE_EVENT_SECTION)
                  Severity: Major
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 2 other locations - About 50 mins to fix
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 631..635
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 643..647

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

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

                          if len(self.HobList) >= 1:
                              self.InfSpecialCommentParser(self.HobList, 
                                                           self.InfSpecialCommentSection, 
                                                           self.FileName, 
                                                           DT.TYPE_HOB_SECTION)
                  Severity: Major
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 2 other locations - About 50 mins to fix
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 631..635
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 637..641

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

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

                          if len(self.BootModeList) >= 1:
                              self.InfSpecialCommentParser(self.BootModeList, 
                                                           self.InfSpecialCommentSection, 
                                                           self.FileName, 
                                                           DT.TYPE_BOOTMODE_SECTION)
                  Severity: Major
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 2 other locations - About 50 mins to fix
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 637..641
                  BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 643..647

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

                  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 (LineNo < len(FileLinesList) - 1):
                                  NextLine = FileLinesList[LineNo].strip()
                  Severity: Minor
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 1 other location - About 45 mins to fix
                  BaseTools/Source/Python/Ecc/Check.py on lines 429..430

                  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

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

                          if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):                      
                  Severity: Minor
                  Found in BaseTools/Source/Python/UPT/Parser/InfParser.py and 1 other location - About 30 mins to fix
                  BaseTools/Source/Python/UPT/Parser/DecParser.py on lines 811..812

                  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