Showing 214 of 421 total issues

Function pass3 has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def pass3(self):
    D = self.DEBUG

    D('Pass #3')

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

  def on_tick(self, task):
    self.display.machine.DEBUG('Display: refresh display')

    gpu = self.display.gpu
    mode = gpu.active_mode
Severity: Minor
Found in ducky/devices/svga.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

File debugging.py has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Virtual machine debugging tools - break points, watch points, etc.

Create "point" that's triggered when a condition is satisfied (e.g.
processor executes instruction on specified address, memory at
Severity: Minor
Found in ducky/debugging.py - About 3 hrs to fix

    Function fix_section_bases has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def fix_section_bases(info, f_out):
      logger, D = get_logger(), get_logger().debug
    
      D('----- * ----- * ----- * ----- * -----')
      D('Fixing base addresses of sections')
    Severity: Minor
    Found in ducky/tools/ld.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

    File boot.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    This file provides necessary code to allow boot up of a virtual machine with
    the correct program running. This code may provide slightly different environment
    when compared to real hardware process, since e.g. external files can be mmap-ed
    into VM's memory for writing.
    Severity: Minor
    Found in ducky/boot.py - About 3 hrs to fix

      Function main has a Cognitive Complexity of 25 (exceeds 5 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 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 jit has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def jit(core, inst):
          regset, reg1, reg2 = core.registers, inst.reg1, inst.reg2
      
          if inst.opcode == DuckyOpcodes.LW:
            reader = core.MEM_IN32
      Severity: Minor
      Found in ducky/cpu/instructions.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 jit has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def jit(core, inst):
          reg1, reg2 = inst.reg1, inst.reg2
          regset = core.registers
      
          if inst.opcode == DuckyOpcodes.STW:
      Severity: Minor
      Found in ducky/cpu/instructions.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

      File storage.py has 304 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      Persistent storage support.
      
      Several different persistent storages can be attached to a virtual machine, each
      with its own id. This module provides methods for manipulating their content.
      Severity: Minor
      Found in ducky/devices/storage.py - About 3 hrs to fix

        Function show_pages has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def show_pages(logger, state, empty_pages = False):
          logger.info('=== Memory pages ===')
        
          GREEN = logger.handlers[0].formatter.green
          WHITE = logger.handlers[0].formatter.white
        Severity: Minor
        Found in ducky/tools/coredump.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

        MMU has 27 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class MMU(ISnapshotable):
          """
          Memory management unit (aka MMU) provides a single point handling all core's memory operations.
          All memory reads and writes must go through this unit, which is then responsible for all
          translations, access control, and caching.
        Severity: Minor
        Found in ducky/cpu/__init__.py - About 3 hrs to fix

          Function status_write has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

            def status_write(self, value):
              """
              Handles writes to `STATUS` register. Starts the IO requested when
              `BIO_READ` or `BIO_WRITE` were set.
              """
          Severity: Minor
          Found in ducky/devices/storage.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

          File errors.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import enum
          
          from .util import UINT32_FMT
          
          class Error(Exception):
          Severity: Minor
          Found in ducky/errors.py - About 2 hrs to fix

            Function read_input has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              def read_input(self):
                def __clear_line():
                  self.write([27, 91, 50, 75, 13])
            
                def __clear_line_from_cursor():
            Severity: Minor
            Found in ducky/console.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 20 (exceeds 5 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/coredump.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 assemble_operands has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              def assemble_operands(cls, ctx, inst, operands):
                from ..asm.ast import RegisterOperand, ReferenceOperand
            
                op = operands[0]
            
            
            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

            MemoryController has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class MemoryController(object):
              """
              Memory controller handles all operations regarding main memory.
            
              :param ducky.machine.Machine machine: virtual machine that owns this controller.
            Severity: Minor
            Found in ducky/mm/__init__.py - About 2 hrs to fix

              File streams.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """
              Streams represent basic IO objects, used by devices for reading or writing
              (streams) of data.
              
              ``Stream`` object encapsulates an actual IO object - ``file``-like stream,
              Severity: Minor
              Found in ducky/streams.py - About 2 hrs to fix

                Function jit has a Cognitive Complexity of 19 (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 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 18 (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/as.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

                Severity
                Category
                Status
                Source
                Language