Showing 214 of 421 total issues

Function run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def run(self):
    """
    Starts reactor loop. Enters endless loop, calling runnable tasks and events,
    and - in case there are no runnable tasks - waits for new events.

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 assemble_operands has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def assemble_operands(cls, ctx, inst, operands):
    ctx.encode(inst, 'reg1', 5, operands[0].operand)

    set_condition = partial(_COND.set_condition, ctx, inst)

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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def __init__(self, filepath = None):
    self._filepath = filepath

    self._dst_section_start = collections.OrderedDict()
    self._dst_section_map = collections.OrderedDict()
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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def __init__(self, machine, **kwargs):
    DEBUG = machine.LOGGER.debug

    self.old_termios = None

Severity: Minor
Found in ducky/streams.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 merge_object_into has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def merge_object_into(info, f_dst, f_src):
  D = get_logger().debug

  D('----- * ----- * ----- * ----- * -----')
  D('Merging %s file', f_src.name)
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 main has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def main():
  from . import add_common_options, parse_options

  parser = optparse.OptionParser()
  add_common_options(parser)
Severity: Minor
Found in ducky/tools/vm.py - About 1 hr to fix

    Function prepare_write has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def prepare_write(self):
        self.DEBUG('%s.prepare_write: name=%s', self.__class__.__name__, self.name)
    
        if self.header.type == SectionTypes.STRINGS:
          self._payload = str2bytes(self.parent.string_table.buff)
    Severity: Minor
    Found in ducky/mm/binary.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 jit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def jit(core, inst):
        regset = core.registers
    
        if inst.immediate_flag == 1:
          reg = inst.reg1
    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 setup_bootloader has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def setup_bootloader(self, filepath, base = None):
        """
        Load :term:`bootloader` into main memory.
    
        In the world of a real hardware, bootloader binary would be transformed
    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 jit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def jit(core, inst):
        regset = core.registers
    
        if inst.immediate_flag == 1:
          reg = inst.reg1
    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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(self, machine, name, memory_size = None, mmio_address = None, memory_address = None, memory_banks = None, modes = None, boot_mode = None, *args, **kwargs):
    Severity: Major
    Found in ducky/devices/svga.py - About 1 hr to fix

      Function write_u16 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def write_u16(self, offset, value):
          self.DEBUG('%s.put: offset=%s, value=%s', self.__class__.__name__, UINT8_FMT(offset), UINT16_FMT(value))
      
          if offset == SimpleVGAPorts.CONTROL:
            if value == SimpleVGACommands.RESET:
      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 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def __init__(self, logger = None, stdin = None, stdout = None, stderr = None):
          self.stdin  = stdin or sys.stdin
          self.stdout = stdout or sys.stdout
          self.stderr = stderr or sys.stderr
      
      
      Severity: Minor
      Found in ducky/machine.py - About 1 hr to fix

        Function pass1 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def pass1(self):
            """
            Pass #1 transforms list of AST nodes into a multiple lists of Slots,
            grouped by sections. It preserves necessary information for later
            resolution of slots referencing each other. Also, list of known
        Severity: Minor
        Found in ducky/asm/__init__.py - About 1 hr to fix

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

            def alloc_pages(self, base = None, count = 1):
              """
              Allocate continuous sequence of anonymous pages.
          
              :param u24 base: if set, start searching pages from this address.
          Severity: Minor
          Found in ducky/mm/__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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def run(self):
              self.machine.DEBUG('irq: router has %i waiting irqs', self.queue.count(True))
          
              for irq, triggered in enumerate(self.queue):
                if triggered is not True:
          Severity: Minor
          Found in ducky/machine.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_open has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def do_open(logger, path, mode = 'rb', klass = None):
              if 'b' not in mode:
                mode += 'b'
          
              stream = open(path, mode)
          Severity: Minor
          Found in ducky/util.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 create_binary_image has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def create_binary_image(f_in, f_out, bio = False):
            D = get_logger().debug
          
            D('create_binary_image: f_in=%s, f_out=%s, bio=%s', f_in.name, f_out.name, bio)
          
          
          Severity: Minor
          Found in ducky/tools/img.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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def execute(core, inst):
              r = core.registers[inst.reg1]
              v = RI_VAL(core, inst, 'reg2')
          
              if inst.opcode == DuckyOpcodes.AND:
          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 _process_input_events has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def _process_input_events(self):
              self.machine.DEBUG('%s.__process_input_events', self.__class__.__name__)
          
              while True:
                e = self._comm_queue.read_in()
          Severity: Minor
          Found in ducky/devices/keyboard.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