Showing 214 of 421 total issues

File util.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import functools
import string

from six import iteritems, integer_types, PY2
Severity: Minor
Found in ducky/util.py - About 2 hrs to fix

    MachineConfig has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MachineConfig(ConfigParser):
      """
      Contains configuration of the whole VM, and provides methods for parsing,
      inspection and extending this configuration.
      """
    Severity: Minor
    Found in ducky/config.py - About 2 hrs to fix

      Machine has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Machine(ISnapshotable, IMachineWorker):
        """
        Virtual machine itself.
        """
      
      
      Severity: Minor
      Found in ducky/machine.py - About 2 hrs to fix

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

          def assemble_operands(cls, ctx, inst, operands):
            from ..asm.ast import RegisterOperand, ReferenceOperand
        
            ctx.encode(inst, 'reg1', 5, operands[0].operand)
        
        
        Severity: Minor
        Found in ducky/cpu/instructions.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 main has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def main():
          import optparse
          from . import add_common_options, parse_options
        
          parser = optparse.OptionParser()
        Severity: Minor
        Found in ducky/tools/ld.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 jit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          def jit(core, inst):
            regset = core.registers
            err = DivideByZeroError(core = core)
        
            if inst.immediate_flag == 1:
        Severity: Minor
        Found in ducky/cpu/instructions.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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def execute(core, inst):
            regset = core.registers
            r = regset[inst.reg1]
            v = RI_VAL(core, inst, 'reg2')
        
        
        Severity: Minor
        Found in ducky/cpu/instructions.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 pass2 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def pass2(self):
            assert self.sections_pass1 is not None
        
            D = self.DEBUG
        
        
        Severity: Minor
        Found in ducky/asm/__init__.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 visit_Expr has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def visit_Expr(self, node):
            self.generic_visit(node)
        
            if type(node.value) != ast.Call:
              return node
        Severity: Minor
        Found in ducky/patch.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 evaluate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def evaluate(core, inst):
            # genuine flags
            if inst.flag in _COND.GFLAGS and inst.value == getattr(core, _COND.FLAGS[inst.flag]):
              return True
        
        
        Severity: Minor
        Found in ducky/cpu/instructions.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 run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def run(self):
            self.machine.DEBUG('%s.run: fds=%s', self.__class__.__name__, self.fds.keys())
        
            try:
              events = self.poll.poll(0.1)
        Severity: Minor
        Found in ducky/reactor.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 process_config_options has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def process_config_options(logger, options, config_file = None, set_options = None, add_options = None, enable_devices = None, disable_devices = None):
          """
          Load VM config file, and apply all necessary changes, as requested by command-line options.
        
          :param logging.Logger logger: ``Logger`` instance to use for logging.
        Severity: Minor
        Found in ducky/tools/vm.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 link_files has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def link_files(info, files_in, file_out):
          D = get_logger().debug
        
          fs_in = []
        
        
        Severity: Minor
        Found in ducky/tools/ld.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 read_u16 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def read_u16(self, offset):
            self.DEBUG('%s.read_u16: offset=%s', self.__class__.__name__, offset)
        
            if offset == SimpleVGAPorts.CONTROL:
              return 0x0000
        Severity: Minor
        Found in ducky/devices/svga.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 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def __init__(self, coreid, cpu, memory_controller):
            super(CPUCore, self).__init__()
        
            config = cpu.machine.config
        
        
        Severity: Minor
        Found in ducky/cpu/__init__.py - About 1 hr to fix

          Function __check_chain has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def __check_chain(self, stage, chain, clean_triggered = False, *args, **kwargs):
              D = self.core.DEBUG
          
              D('__check_chain: stage=%s, chain=%s, clean_triggered=%s', stage, chain, clean_triggered)
          
          
          Severity: Minor
          Found in ducky/debugging.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 setup_hdt has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def setup_hdt(self):
              """
              Initialize memory area containing :ref:`HDT`.
          
              If VM config file specifies ``HDT`` image file, it is loaded, otherwise HDT
          Severity: Minor
          Found in ducky/boot.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 disassemble_mnemonic has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def disassemble_mnemonic(inst):
              if inst.flag in _COND.GFLAGS:
                return 'b%s%s' % ('n' if inst.value == 0 else '', _COND.MNEMONICS[inst.flag])
          
              else:
          Severity: Minor
          Found in ducky/cpu/instructions.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 main has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          def main():
            parser = optparse.OptionParser()
            add_common_options(parser)
          
            parser.add_option('-i', dest = 'file_in', action = 'append', default = [], help = 'File to inspect')
          Severity: Minor
          Found in ducky/tools/objdump.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 do_log_cpu_core_state has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          def do_log_cpu_core_state(core, logger = None, disassemble = True, inst_set = None):
            """
            Log state of a CPU core. Content of its registers, and other interesting or
            useful internal variables are logged.
          
          
          Severity: Minor
          Found in ducky/cpu/__init__.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

          Severity
          Category
          Status
          Source
          Language