hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py

Summary

Maintainability
F
5 days
Test Coverage

File msilib.py has 601 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Microsoft Installer Library
# (C) 2003 Martin v. Loewis

import win32com.client.gencache
import win32com.client
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 1 day to fix

    Function gen_sequence has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def gen_sequence(destpath, msipath):
        dir = os.path.dirname(destpath)
        d = MakeInstaller()
        seqmsi = d.OpenDatabase(msipath,
                win32com.client.constants.msiOpenDatabaseModeReadOnly)
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.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 make_short has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_short(self, file):
            file = re.sub(r'[\?|><:/*"+,;=\[\]]', '_', file) # restrictions on short names
            parts = file.split(".")
            if len(parts)>1:
                suffix = parts[-1].upper()
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.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 sql has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def sql(self):
            fields = []
            keys = []
            self.fields.sort()
            fields = [None]*len(self.fields)
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.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 gen_schema has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def gen_schema(destpath, schemapath):
        d = MakeInstaller()
        schema = d.OpenDatabase(schemapath,
                win32com.client.constants.msiOpenDatabaseModeReadOnly)
    
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.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 commit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def commit(self, db):
            self.file.close()
            try:
                os.unlink(self.name+".cab")
            except OSError:
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.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 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, db, name, x, y, w, h, attr, title, first, default, cancel):
    Severity: Major
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 1 hr to fix

      Function control has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def control(self, name, type, x, y, w, h, attr, prop, text, next, help):
      Severity: Major
      Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 1 hr to fix

        Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, db, id, title, desc, display, level = 1,
        Severity: Major
        Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 1 hr to fix

          Function radiogroup has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def radiogroup(self, name, x, y, w, h, attr, prop, text, next):
          Severity: Major
          Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 1 hr to fix

            Function checkbox has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def checkbox(self, name, x, y, w, h, attr, prop, text, next):
            Severity: Major
            Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 1 hr to fix

              Function add_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def add_data(db, table, values):
                  d = MakeInstaller()
                  v = db.OpenView("SELECT * FROM `%s`" % table)
                  count = v.ColumnInfo(0).FieldCount
                  r = d.CreateRecord(count)
              Severity: Minor
              Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.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 pushbutton has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def pushbutton(self, name, x, y, w, h, attr, text, next):
              Severity: Major
              Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 1 hr to fix

                Function change_sequence has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified):
                    "Change the sequence number of an action in a sequence list"
                    for i in range(len(seq)):
                        if seq[i][0] == action:
                            if cond is _Unspecified:
                Severity: Minor
                Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 55 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function init_database has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def init_database(name, schema,
                Severity: Major
                Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 50 mins to fix

                  Function text has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def text(self, name, x, y, w, h, attr, text):
                  Severity: Major
                  Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 50 mins to fix

                    Function add has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def add(self, name, x, y, w, h, text, value = None):
                    Severity: Major
                    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 50 mins to fix

                      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def __init__(self, db, cab, basedir, physical, _logical, default, componentflags=None):
                      Severity: Major
                      Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 50 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if table == "Binary":
                                                fname = rec[0]+".bin"
                                                open(os.path.join(dir,fname),"wb").write(bytes)
                                                rec.append(Binary(fname))
                                            else:
                        Severity: Major
                        Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 45 mins to fix

                          Function bitmap has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def bitmap(self, name, x, y, w, h, text):
                          Severity: Minor
                          Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 45 mins to fix

                            Function start_component has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None):
                                    """Add an entry to the Component table, and make this component the current for this
                                    directory. If no component name is given, the directory name is used. If no feature
                                    is given, the current feature is used. If no flags are given, the directory's default
                                    flags are used. If no keyfile is given, the KeyPath is left null in the Component
                            Severity: Minor
                            Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

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

                                def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None):
                            Severity: Minor
                            Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 35 mins to fix

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

                                  def line(self, name, x, y, w, h):
                              Severity: Minor
                              Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py - About 35 mins to fix

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

                                    machine = struct.unpack("<H", header[pe_offset+4:pe_offset+6])[0]
                                vector-uefi/fd/tool/chipsec/hal/spi_descriptor.py on lines 174..174
                                vector-uefi/fd/tool/chipsec/hal/spi_descriptor.py on lines 176..176
                                vector-uefi/fd/tool/chipsec/hal/spi_descriptor.py on lines 178..178

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

                                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 condition(self, action, condition):
                                        add_data(self.dlg.db, "ControlCondition",
                                                 [(self.dlg.name, self.name, action, condition)])
                                Severity: Minor
                                Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py and 1 other location - About 40 mins to fix
                                AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py on lines 607..609

                                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

                                    def mapping(self, ev, attr):
                                        add_data(self.dlg.db, "EventMapping",
                                                 [(self.dlg.name, self.name, ev, attr)])
                                Severity: Minor
                                Found in AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py and 1 other location - About 40 mins to fix
                                AppPkg/Applications/Python/Python-2.7.2/Tools/msi/msilib.py on lines 611..613

                                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

                                There are no issues that match your filters.

                                Category
                                Status