hackedteam/vector-edk

View on GitHub
vector-uefi/fd/tool/chipsec_main.py

Summary

Maintainability
D
2 days
Test Coverage

File chipsec_main.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/local/bin/python
#CHIPSEC: Platform Security Assessment Framework
#Copyright (c) 2010-2014, Intel Corporation
# 
#This program is free software; you can redistribute it and/or
Severity: Minor
Found in vector-uefi/fd/tool/chipsec_main.py - About 5 hrs to fix

    Function run_loaded_modules has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_loaded_modules():
        from chipsec.module_common import ModuleResult
    
        failed   = []
        errors   = []
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.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 old_run_module has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def old_run_module( module_path, module_argv ):
        module_path = module_path.replace( os.sep, '.' )
        module = import_module(module_path)
        if module == None and _importlib: return None
        run_it = True
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.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 load_my_modules has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_my_modules():
        #
        # Step 1.
        # Load modules common to all supported platforms
        #
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.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 verify_module_tags has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def verify_module_tags(module):
        run_it = True
        if len(USER_MODULE_TAGS) > 0 or _list_tags:
            run_it = False
            module_tags= module.get_tags()
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.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 get_module_name has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_module_name(full_path):
        name = full_path
        # case #1, the full path: remove prefix
        if full_path.startswith(CHIPSEC_FOLDER+os.path.sep):
            name = full_path.replace ( CHIPSEC_FOLDER+os.path.sep, '')
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.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 import_module has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def import_module(module_path):
        module = None
        if not MODPATH_RE.match(module_path):
            logger().error( "Invalid module path: %s" % module_path )
        else:
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.py - About 35 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 load_modules_from_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_modules_from_path( from_path ):
        if logger().VERBOSE: logger().log_bad( os.path.abspath( from_path ) )
        for dirname, subdirs, mod_fnames in os.walk( os.path.abspath( from_path ) ):
            for modx in mod_fnames:
                if fnmatch.fnmatch( modx, '*.py' ) and not fnmatch.fnmatch( modx, '__init__.py' ):
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.py - About 35 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 run_module has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_module( modx, module_argv ):
        from chipsec.module_common import ModuleResult
        result = None
        try:
            if not modx.do_import(): return ModuleResult.ERROR
    Severity: Minor
    Found in vector-uefi/fd/tool/chipsec_main.py - About 35 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

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

            for mt in module_tags:
                if _list_tags:
                    if mt not in AVAILABLE_TAGS: AVAILABLE_TAGS.append(mt)
                elif mt in  USER_MODULE_TAGS:
                    run_it = True
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec_main.py and 1 other location - About 1 hr to fix
    vector-uefi/fd/tool/chipsec_main.py on lines 167..171

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

            for mt in module_tags:
                if _list_tags:
                    if mt not in AVAILABLE_TAGS: AVAILABLE_TAGS.append(mt)
                elif mt in  USER_MODULE_TAGS:
                    run_it = True
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec_main.py and 1 other location - About 1 hr to fix
    vector-uefi/fd/tool/chipsec_main.py on lines 140..144

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    def f_mod(x):
        return ( x.find('__init__') == -1 and ZIP_MODULES_RE.match(x) )
    Severity: Major
    Found in vector-uefi/fd/tool/chipsec_main.py and 9 other locations - About 30 mins to fix
    vector-uefi/fd/tool/chipsec/helper/oshelper.py on lines 58..59
    vector-uefi/fd/tool/chipsec_util.py on lines 66..67
    vector-uefi/fd/tool/chipsec_util.py on lines 72..73
    vector-uefi/fd/tool/flash.py on lines 73..74
    vector-uefi/fd/tool/flash.py on lines 79..80
    vector-uefi/fd/tool/patch.py on lines 73..74
    vector-uefi/fd/tool/patch.py on lines 79..80
    vector-uefi/fd/tool/test.py on lines 73..74
    vector-uefi/fd/tool/test.py on lines 79..80

    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