cea-sec/miasm

View on GitHub
miasm/jitter/jitload.py

Summary

Maintainability
F
4 days
Test Coverage

File jitload.py has 456 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import warnings
from functools import wraps
from collections import namedtuple
try:
Severity: Minor
Found in miasm/jitter/jitload.py - About 6 hrs to fix

    Function runiter_once has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def runiter_once(self, pc):
            """Iterator on callbacks results on code running from PC.
            Check exceptions before breakpoints."""
    
            self.pc = pc
    Severity: Minor
    Found in miasm/jitter/jitload.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

    Jitter has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Jitter(object):
    
        "Main class for JIT handling"
    
        C_Gen = CGen
    Severity: Minor
    Found in miasm/jitter/jitload.py - About 2 hrs to fix

      Function __init__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, lifter, jit_type="gcc"):
              """Init an instance of jitter.
              @lifter: Lifter instance for this architecture
              @jit_type: JiT backend to use. Available options are:
                  - "gcc"
      Severity: Minor
      Found in miasm/jitter/jitload.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 __init__ has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, lifter, jit_type="gcc"):
              """Init an instance of jitter.
              @lifter: Lifter instance for this architecture
              @jit_type: JiT backend to use. Available options are:
                  - "gcc"
      Severity: Minor
      Found in miasm/jitter/jitload.py - About 1 hr to fix

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

            def call_callbacks(self, bitflag, *args):
                """Call each callbacks associated with bit set in bitflag. While
                callbacks return True, continue with next callback.
                Iterator on other results"""
        
        
        Severity: Minor
        Found in miasm/jitter/jitload.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 continue_run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def continue_run(self, step=False, trace=False):
                """PRE: init_run.
                Continue the run of the current session until iterator returns or run is
                set to False.
                If step is True, run only one time.
        Severity: Minor
        Found in miasm/jitter/jitload.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 remove_callback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def remove_callback(self, callback):
                """Remove the callback from the list.
                Return the list of empty keys (removed)"""
        
                to_check = set()
        Severity: Minor
        Found in miasm/jitter/jitload.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 3 locations. Consider refactoring.
        Open

                while ((max_char is None or l < max_char) and
                       self.vm.get_mem(tmp, 1) != b"\x00"):
                    tmp += 1
                    l += 1
        Severity: Major
        Found in miasm/jitter/jitload.py and 2 other locations - About 2 hrs to fix
        miasm/os_dep/common.py on lines 16..19
        miasm/os_dep/common.py on lines 28..31

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

        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

                try:
                    if jit_type == "llvm":
                        from miasm.jitter.jitcore_llvm import JitCore_LLVM as JitCore
                    elif jit_type == "python":
                        from miasm.jitter.jitcore_python import JitCore_Python as JitCore
        Severity: Major
        Found in miasm/jitter/jitload.py and 1 other location - About 2 hrs to fix
        miasm/jitter/jitload.py on lines 227..236

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

        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

                    elif arch_name == "msp430":
                        from miasm.jitter.arch import JitCore_msp430 as jcore
                    elif arch_name == "mips32":
                        from miasm.jitter.arch import JitCore_mips32 as jcore
                    elif arch_name == "ppc32":
        Severity: Major
        Found in miasm/jitter/jitload.py and 1 other location - About 2 hrs to fix
        miasm/jitter/jitload.py on lines 251..259

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

        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 res in self.exceptions_handler(exception_flag, self):
                    if res is not True:
                        if isinstance(res, Iterator):
                            for tmp in res:
                                yield tmp
        Severity: Major
        Found in miasm/jitter/jitload.py and 1 other location - About 1 hr to fix
        miasm/jitter/jitload.py on lines 380..386

        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

                for res in self.exceptions_handler(exception_flag, self):
                    if res is not True:
                        if isinstance(res, Iterator):
                            for tmp in res:
                                yield tmp
        Severity: Major
        Found in miasm/jitter/jitload.py and 1 other location - About 1 hr to fix
        miasm/jitter/jitload.py on lines 402..408

        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

        There are no issues that match your filters.

        Category
        Status