Showing 214 of 421 total issues

File instructions.py has 2413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import ctypes
import enum
import logging
import sys

Severity: Major
Found in ducky/cpu/instructions.py - About 6 days to fix

    Function jit has a Cognitive Complexity of 198 (exceeds 5 allowed). Consider refactoring.
    Open

      def jit(core, inst):
        core.DEBUG('JIT: %s', inst)
    
        regset = core.registers
        ip = Registers.IP.value
    Severity: Minor
    Found in ducky/cpu/instructions.py - About 4 days 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 118 (exceeds 5 allowed). Consider refactoring.
    Open

      def jit(core, inst):
        regset = core.registers
        reg1 = inst.reg1
    
        if inst.immediate_flag == 1:
    Severity: Minor
    Found in ducky/cpu/instructions.py - About 2 days 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 __init__.py has 905 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import functools
    import sys
    
    from six import iterkeys, itervalues, iteritems
    from six.moves import range
    Severity: Major
    Found in ducky/cpu/__init__.py - About 2 days to fix

      Function resolve_relocations has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
      Open

      def resolve_relocations(info, f_out, f_ins):
        logger, D = get_logger(), get_logger().debug
      
        D('')
        D('----- * ----- * ----- * ----- * -----')
      Severity: Minor
      Found in ducky/tools/ld.py - About 1 day 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 __init__.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from six import iteritems, itervalues
      from six.moves import range
      
      from ..interfaces import ISnapshotable
      from ..errors import AccessViolationError, InvalidResourceError
      Severity: Major
      Found in ducky/mm/__init__.py - About 1 day to fix

        File math_copro.py has 520 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Stack-based coprocessor, providing several arithmetic operations with "long"
        numbers.
        
        Coprocessor's instructions operates on a stack of (by default) 8 slots.
        Severity: Major
        Found in ducky/cpu/coprocessor/math_copro.py - About 1 day to fix

          File __init__.py has 490 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import collections
          import ctypes
          import functools
          import os.path
          import subprocess
          Severity: Minor
          Found in ducky/asm/__init__.py - About 7 hrs to fix

            File ld.py has 450 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import ast
            import collections
            import logging
            import os
            import re
            Severity: Minor
            Found in ducky/tools/ld.py - About 6 hrs to fix

              File parser.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import ply.yacc
              
              from .lexer import tokens  # NOQA
              from .ast import LabelNode, GlobalDirectiveNode, FileDirectiveNode, SectionDirectiveNode, DataSectionDirectiveNode, TextSectionDirectiveNode, SetDirectiveNode
              from .ast import StringNode, AsciiNode, SpaceNode, AlignNode, ByteNode, ShortNode, WordNode, InstructionNode, ExpressionNode
              Severity: Minor
              Found in ducky/asm/parser.py - About 5 hrs to fix

                Function jit has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                Open

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

                File machine.py has 384 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """
                :py:class:`ducky.machine.Machine` is *the* virtual machine. Each instance
                represents self-contained virtual machine, with all its devices, memory, CPUs
                and other necessary properties.
                """
                Severity: Minor
                Found in ducky/machine.py - About 5 hrs to fix

                  CPUCore has 39 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class CPUCore(ISnapshotable, IMachineWorker):
                    """
                    This class represents the main workhorse, one of CPU cores. Reads
                    instructions, executes them, has registers, caches, handles interrupts,
                    ...
                  Severity: Minor
                  Found in ducky/cpu/__init__.py - About 5 hrs to fix

                    Function save_object_file has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def save_object_file(logger, sections, file_out, options):
                      logger = get_logger()
                      D = logger.debug
                    
                      if os.path.exists(file_out) and not options.force:
                    Severity: Minor
                    Found in ducky/tools/as.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 pass1 has a Cognitive Complexity of 33 (exceeds 5 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 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 show_symbols has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def show_symbols(options, f):
                      I = get_logger().info
                    
                      def to_ascii(buff):
                        ret = ['' for _ in range(0, len(buff))]
                    Severity: Minor
                    Found in ducky/tools/objdump.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 show_disassemble has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def show_disassemble(f):
                      logger, I = get_logger(), get_logger().info
                    
                      I('=== Disassemble ==')
                      I('')
                    Severity: Minor
                    Found in ducky/tools/objdump.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

                    File vm.py has 351 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import six.moves
                    import urllib
                    
                    if not hasattr(urllib, 'parse'):
                      urllib.parse = six.moves.urllib.parse
                    Severity: Minor
                    Found in ducky/tools/vm.py - About 4 hrs to fix

                      File binary.py has 336 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import enum
                      
                      from six import itervalues, PY2
                      from six.moves import range
                      
                      
                      Severity: Minor
                      Found in ducky/mm/binary.py - About 4 hrs to fix

                        File svga.py has 332 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        """
                        SimpleVGA is very basic implementation of VGA-like device, with text
                        and graphic modes.
                        """
                        
                        
                        Severity: Minor
                        Found in ducky/devices/svga.py - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language