hackedteam/vector-edk

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

Summary

Maintainability
F
6 days
Test Coverage

File DecParser.py has 668 lines of code (exceeds 250 allowed). Consider refactoring.
Open

## @file
# This file is used to parse DEC file. It will consumed by DecParser
#
# Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
#
Severity: Major
Found in BaseTools/Source/Python/UPT/Parser/DecParser.py - About 1 day to fix

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

        def Parse(self):
            HeadComments = []
            TailComments = []
            
            #======================================================================
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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 _SectionHeaderParser has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def _SectionHeaderParser(self):
            if self._RawData.CurrentLine[0] != DT.TAB_SECTION_START or self._RawData.CurrentLine[-1] != DT.TAB_SECTION_END:
                self._LoggerError(ST.ERR_DECPARSE_SECTION_IDENTIFY)
            
            RawSection = self._RawData.CurrentLine[1:-1].strip().upper()
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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

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

        def ParseDecComment(self):
            IsFileHeader = False
            IsBinaryHeader = False
            FileHeaderLineIndex = -1
            BinaryHeaderLineIndex = -1
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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 _CheckReDefine has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def _CheckReDefine(self, Key, Scope = None):
            if not Scope:
                Scope = self._RawData.CurrentScope
                return
            
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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 _TryBackSlash has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def _TryBackSlash(self, ProcessedLine, ProcessedComments):
            CatLine = ''
            Comment = ''
            Line = ProcessedLine
            CommentList = ProcessedComments
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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 _UserExtentionSectionParser has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def _UserExtentionSectionParser(self):
            self._RawData.CurrentScope = []
            ArchList = set()
            Section = self._RawData.CurrentLine[1:-1]
            
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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 _ParseItem has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _ParseItem(self):
            Line = self._RawData.CurrentLine
            TokenList = Line.split(DT.TAB_VALUE_SPLIT)
            if len(TokenList) < 4:
                self._LoggerError(ST.ERR_DECPARSE_PCD_SPLIT)
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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 _ParseItem has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _ParseItem(self):
            Line = self._RawData.CurrentLine
            TokenList = GetSplitValueList(Line, DT.TAB_EQUAL_SPLIT, 1)
            if len(TokenList) < 2:
                self._LoggerError(ST.ERR_DECPARSE_CGUID)
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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 BlockStart has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def BlockStart(self):
            self._CurItems = []
            for Header in self._RawData.CurrentScope:
                if Header in self._Headers:
                    self._LoggerError(ST.ERR_DECPARSE_UE_DUPLICATE)
    Severity: Minor
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.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

                            if Other[:-1] == SubValue[:-1]:
                                self._LoggerError(ST.ERR_DECPARSE_REDEFINE % (Key, Value[1]))
                                return
                        continue
    Severity: Major
    Found in BaseTools/Source/Python/UPT/Parser/DecParser.py - About 45 mins to fix

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

          def _ParseItem(self):
              Line = self._RawData.CurrentLine
              TokenList = GetSplitValueList(Line, DT.TAB_VALUE_SPLIT)
              if len(TokenList) != 2:
                  self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_SPLIT) 
      Severity: Minor
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.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

          def _SetPackageGuid(self, Token):
              if self.ItemObject.GetPackageGuid():
                  self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_GUID)
              if not CheckGuidRegFormat(Token):
                  self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGGUID)
      Severity: Major
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.py and 1 other location - About 3 hrs to fix
      BaseTools/Source/Python/UPT/Parser/DecParser.py on lines 454..459

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

      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

          def _SetPackageName(self, Token):
              if self.ItemObject.GetPackageName():
                  self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_NAME)
              if not IsValidWord(Token):
                  self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGNAME)
      Severity: Major
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.py and 1 other location - About 3 hrs to fix
      BaseTools/Source/Python/UPT/Parser/DecParser.py on lines 461..466

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

      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 'COMMON' in ArchList and len(ArchList) > 1:
                  self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMON)
      Severity: Minor
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.py and 1 other location - About 50 mins to fix
      BaseTools/Source/Python/UPT/Parser/DecParser.py on lines 917..918

      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 'COMMON' in ArchList and len(ArchList) > 1:
                  self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMON)
      Severity: Minor
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.py and 1 other location - About 50 mins to fix
      BaseTools/Source/Python/UPT/Parser/DecParser.py on lines 990..991

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

              if not IsValidPath(Line, self._RawData.PackagePath):
                  self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Line) 
      Severity: Minor
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.py and 1 other location - About 40 mins to fix
      BaseTools/Source/Python/UPT/Parser/DecParser.py on lines 528..529

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

      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 IsValidPath(Value, self._RawData.PackagePath):
                  self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Value)
      Severity: Minor
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.py and 1 other location - About 40 mins to fix
      BaseTools/Source/Python/UPT/Parser/DecParser.py on lines 490..491

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

      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

                  not(Comment.startswith(DT.TAB_SPECIAL_COMMENT) \
                  and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0):
      Severity: Minor
      Found in BaseTools/Source/Python/UPT/Parser/DecParser.py and 1 other location - About 30 mins to fix
      BaseTools/Source/Python/UPT/Parser/InfParser.py on lines 655..655

      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