hackedteam/vector-edk

View on GitHub
BaseTools/Source/Python/GenFds/EfiSection.py

Summary

Maintainability
F
6 days
Test Coverage

Function GenSection has a Cognitive Complexity of 123 (exceeds 5 allowed). Consider refactoring.
Open

    def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}) :
        
        if self.FileName != None and self.FileName.startswith('PCD('):
            self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName)
        """Prepare the parameter of GenSection"""
Severity: Minor
Found in BaseTools/Source/Python/GenFds/EfiSection.py - About 2 days 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 GenSection has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}) :
Severity: Minor
Found in BaseTools/Source/Python/GenFds/EfiSection.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if ImageObj.SectionAlignment < 0x400:
                                self.Alignment = str (ImageObj.SectionAlignment)
                            else:
                                self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
    
    Severity: Major
    Found in BaseTools/Source/Python/GenFds/EfiSection.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if os.path.exists(MapFile):
                                  CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')
                                  if not os.path.exists(CopyMapFile) or \
                                      (os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):
                                      shutil.copyfile(MapFile, CopyMapFile)
      Severity: Major
      Found in BaseTools/Source/Python/GenFds/EfiSection.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not os.path.exists(FileBeforeStrip) or \
                                    (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):
                                    shutil.copyfile(File, FileBeforeStrip)
                                StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
        Severity: Major
        Found in BaseTools/Source/Python/GenFds/EfiSection.py - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

                  return OutputFileList, self.Alignment
          Severity: Major
          Found in BaseTools/Source/Python/GenFds/EfiSection.py - About 30 mins to fix

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

                                if File[(len(File)-4):] == '.efi':
                                    MapFile = File.replace('.efi', '.map')
                                    if os.path.exists(MapFile):
                                        CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')
                                        if not os.path.exists(CopyMapFile) or \
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 1 other location - About 1 day to fix
            BaseTools/Source/Python/GenFds/DataSection.py on lines 70..76

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

            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 self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
                                    ImageObj = PeImageClass (File)
                                    if ImageObj.SectionAlignment < 0x400:
                                        self.Alignment = str (ImageObj.SectionAlignment)
                                    else:
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 2 other locations - About 5 hrs to fix
            BaseTools/Source/Python/GenFds/FfsInfStatement.py on lines 641..646
            BaseTools/Source/Python/GenFds/FfsInfStatement.py on lines 680..685

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

            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 FfsInf.KeepReloc != None:
                                NoStrip = FfsInf.KeepReloc
                            elif FfsInf.KeepRelocFromRule != None:
                                NoStrip = FfsInf.KeepRelocFromRule
                            elif self.KeepReloc != None:
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 1 other location - About 2 hrs to fix
            BaseTools/Source/Python/GenFds/FfsInfStatement.py on lines 622..628

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

            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 os.path.isabs(Filename):
                            Filename = os.path.normpath(Filename)
                        else:
                            Filename = os.path.normpath(os.path.join(FfsInf.EfiOutputPath, Filename))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 1 other location - About 2 hrs to fix
            BaseTools/Source/Python/GenFds/FfsInfStatement.py on lines 600..603

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

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

                            OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 3 other locations - About 1 hr to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 118..118
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 156..156
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 203..203

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

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

                            OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 3 other locations - About 1 hr to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 156..156
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 174..174
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 203..203

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

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

                            OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 3 other locations - About 1 hr to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 118..118
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 174..174
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 203..203

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

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

                            OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 3 other locations - About 1 hr to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 118..118
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 156..156
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 174..174

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

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

                                OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 2 other locations - About 1 hr to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 128..128
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 224..224

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

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

                                OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 2 other locations - About 1 hr to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 183..183
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 224..224

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

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

                                OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
            Severity: Major
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 2 other locations - About 1 hr to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 128..128
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 183..183

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

            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 BuildNum != None and BuildNum != '':
                                BuildNumTuple = ('-j', BuildNum)
                            else:
                                BuildNumTuple = tuple()
            Severity: Minor
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 1 other location - About 55 mins to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 112..115

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

            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 BuildNum != None and BuildNum != '':
                                BuildNumTuple = ('-j', BuildNum)
                            else:
                                BuildNumTuple = tuple()
            Severity: Minor
            Found in BaseTools/Source/Python/GenFds/EfiSection.py and 1 other location - About 55 mins to fix
            BaseTools/Source/Python/GenFds/EfiSection.py on lines 142..145

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

            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