petspats/pyha

View on GitHub

Showing 108 of 164 total issues

File redbaron_transforms.py has 915 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import textwrap
from contextlib import suppress

from parse import parse
Severity: Major
Found in pyha/conversion/redbaron_transforms.py - About 2 days to fix

    File type_transforms.py has 573 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import copy
    import inspect
    import logging
    import time
    from collections import deque
    Severity: Major
    Found in pyha/conversion/type_transforms.py - About 1 day to fix

      Function transform_call has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
      Open

      def transform_call(red_node):
          """
          Converts Python style function calls to VHDL style:
          self.d(a) -> d(self, a)
      
      
      Severity: Minor
      Found in pyha/conversion/redbaron_transforms.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

      Function transform_dynamic_lists has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
      Open

      def transform_dynamic_lists(red_node):
          data = VHDLModule('-', convert_obj)
      
          dynamic_lists = [x for x in data.elems if isinstance(x, VHDLList) and not x.elements_compatible_typed]
          for x in dynamic_lists:
      Severity: Minor
      Found in pyha/conversion/redbaron_transforms.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

      Function simulate has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
      Open

      def simulate(model, *args, simulations=None, conversion_path=None, input_types=None,
                   pipeline_flush='self.DELAY', trace=False):
          """
          Run simulations on model.
      
      
      Severity: Minor
      Found in pyha/simulation/simulation_interface.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

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

          def __init__(self, obj, datamodel=None):
              """ Convert object and all childs to VHDL """
              with RecursiveConverter.in_progress:
                  self.obj = obj
                  self.class_name = obj.__class__.__name__
      Severity: Minor
      Found in pyha/conversion/conversion.py - About 7 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

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

      class Sfix:
          """
          Signed fixed-point type. Default fixed-point format in Pyha is ``Sfix(left=0, right=-17)`` (17 fractional bits + sign)
          , representing values in range [-1, 1] ``(2**0)`` with resolution of 0.0000076 ``(2**-17)``.
      
      
      Severity: Minor
      Found in pyha/common/fixed_point.py - About 5 hrs to fix

        File core.py has 378 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import logging
        import sys
        import time
        import weakref
        from collections import UserList
        Severity: Minor
        Found in pyha/common/core.py - About 5 hrs to fix

          File fixed_point.py has 378 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import logging
          import math
          
          import numpy as np
          
          
          Severity: Minor
          Found in pyha/common/fixed_point.py - About 5 hrs to fix

            File simulation_interface.py has 366 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import logging
            import os
            import shutil
            import subprocess
            import sys
            Severity: Minor
            Found in pyha/simulation/simulation_interface.py - About 4 hrs to fix

              Function transform_auto_resize has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
              Open

              def transform_auto_resize(red_node):
                  """ Auto resize on Sfix assignments
                   Examples (depend on initial Sfix type):
                       self.sfix_reg = a        ->   self.sfix_reg = resize(a, 5, -29, fixed_wrap, fixed_round)
                       self.sfix_list[0] = a    ->   self.sfix_list[0] = resize(a, 0, 0, fixed_saturate, fixed_round)
              Severity: Minor
              Found in pyha/conversion/redbaron_transforms.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 __setitem__ has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __setitem__(self, i, y):
                      """ Implements auto-resize feature, ie resizes all assigns to Sfix registers.
                      Also implements the register behaviour i.e saves assigned value to shadow variable, that is later used by the '_pyha_update_registers' function.
                      """
                      if hasattr(self.data[0], '_pyha_update_registers'):
              Severity: Minor
              Found in pyha/common/core.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 init_vhdl_type has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              def init_vhdl_type(name, current_val, initial_val=None, parent=None):
                  from pyha.conversion.conversion import RecursiveConverter
                  if type(current_val) == int or type(current_val) == np.int64:
                      return VHDLInt(name, current_val, initial_val, parent)
                  elif type(current_val) == bool or type(current_val) == np.bool_:
              Severity: Minor
              Found in pyha/conversion/type_transforms.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 __setattr__ has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __setattr__(self, name, value):
                      """ Implements auto-resize feature, ie resizes all assigns to Sfix registers.
                      Also implements the register behaviour i.e saves assigned value to shadow variable, that is later used by the '_pyha_update_registers' function.
                      """
                      if hasattr(self, '_pyha_is_initialization') or self._pyha_is_local() or not RegisterBehaviour.is_enabled():
              Severity: Minor
              Found in pyha/common/core.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 transform_resize_arguments has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              def transform_resize_arguments(red_node):
                  """ Replace 'wrap' -> fixed_wrap
                      'saturate' -> fixed_saturate
                      'truncate' -> fixed_truncate
                      'round' -> fixed_round
              Severity: Minor
              Found in pyha/conversion/redbaron_transforms.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 super_getattr has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              def super_getattr(obj, attr, is_local=False):
                  for part in attr.split('.'):
                      if not is_local:
                          if part == 'self' or part == 'self_next':
                              continue
              Severity: Minor
              Found in pyha/conversion/redbaron_transforms.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 range_to_vhdl has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

                  def range_to_vhdl(self, pyrange):
                      # this for was transforemed by 'redbaron_pyfor_to_vhdl'
                      if str(self.iterator) == '\\_i_\\':
                          return f"{pyrange}'range"
              
              
              Severity: Minor
              Found in pyha/conversion/redbaron_transforms.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

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

              class Complex:
                  """
                  Complex number with ``.real`` and ``.imag`` elements. Default type is ``Complex(left=0, right=-17)``.
              
                  :param val:
              Severity: Minor
              Found in pyha/common/complex.py - About 3 hrs to fix

                Function convert has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                def convert(red: Node, obj=None):
                    set_convert_obj(obj)
                
                    # delete all non convertable functions from redbaron AST
                    # coding style is akward because of some redbaron bugs...
                Severity: Minor
                Found in pyha/conversion/redbaron_transforms.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 __call__ has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __call__(cls, *args, **kwargs):
                        cls._pyha_is_initialization = True  # flag to avoid problems in __setattr__
                        ret = super(Meta, cls).__call__(*args, **kwargs)
                
                        if not SimulationRunning.is_enabled():  # local objects are simplified, they need no reset or register behaviour
                Severity: Minor
                Found in pyha/common/core.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