capocchi/DEVSimPy

View on GitHub
Components.py

Summary

Maintainability
F
4 days
Test Coverage

File Components.py has 670 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# Components.py ---
#                    --------------------------------
Severity: Major
Found in Components.py - About 1 day to fix

    Function OnEditor has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

        def OnEditor(self, event):
            """ Method that edit the python code of associated devs model of the Block.
            """
            from Container import ShapeCanvas
    
    
    Severity: Minor
    Found in Components.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

    Function CreateBlock has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def CreateBlock(*argv, **kwargs):
            """ Create Block from python_file and other info coming from wizard.
            """
            
            from Container import iPort, oPort, MsgBoxError
    Severity: Minor
    Found in Components.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 GetModule has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def GetModule(filename):
            """ Give module object from python file path. Warning, the name of python_file must be the same of the classe name.
            """
    
            dir_name = os.path.dirname(filename)
    Severity: Minor
    Found in Components.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 GetArgs has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def GetArgs(cls = None):
        """ Get behavioral attribute from python file through constructor class.
        """
    
        if inspect.isclass(cls):
    Severity: Minor
    Found in Components.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

    DEVSComponent has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DEVSComponent:
        """
        """
    
        def __init__(self):
    Severity: Minor
    Found in Components.py - About 2 hrs to fix

      Function Rename has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def Rename(filename:str, new_name:str)->bool:
              """ Rename the filename with the new_name.
              """
                  
              old_bn = os.path.basename(filename)
      Severity: Minor
      Found in Components.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 Load has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def Load(filename, label, canvas):
              """ Load component from filename.
              """
              from Container import Diagram
              #assert(filename.endswith('.dsp'))
      Severity: Minor
      Found in Components.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 GetClass has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def GetClass(elem):
          """ Get python class from filename.
          """
      
          clsmembers = getClassMember(elem)
      Severity: Minor
      Found in Components.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 setBlock has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def setBlock(self, devs):
              """ 
              Set the Block.
              """
              if devs is not None:
      Severity: Minor
      Found in Components.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 Load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def Load(filename, label):
              """ Load CMD from filename.
              """
              from Container import ContainerBlock, iPort, oPort
              assert(filename.endswith('.cmd'))
      Severity: Minor
      Found in Components.py - About 45 mins 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 BlockModelAdapter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def BlockModelAdapter(cls, label="", specific_behavior=""):
              """ Return block model considering its class hierarchy
                  The implementation depends only of the argument of the class. There is no dependance with the collector module (in comment bellow)
              """
              from Container import DiskGUI, ScopeGUI, CodeBlock
      Severity: Minor
      Found in Components.py - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, *argv, **kwargs):
              """ Constructor.
              """
              # local copy
              self._canvas = kwargs['canvas'] if 'id' in kwargs else None
      Severity: Minor
      Found in Components.py - About 35 mins 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

      Avoid too many return statements within this function.
      Open

                      return False
      Severity: Major
      Found in Components.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return None
        Severity: Major
        Found in Components.py - About 30 mins to fix

          Function ChekFilename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def ChekFilename(filename, model):
                  """ static method to correct the error occurring when the filename is not corresponding with values of paths
                      (model and python) embedded in the .amd (dat file). This error occurs when the user copy and past a .amd model into
                      an another directory.
                  """
          Severity: Minor
          Found in Components.py - About 25 mins 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

          There are no issues that match your filters.

          Category
          Status