capocchi/DEVSimPy

View on GitHub
DEVSKernel/PyPDEVS/old/DEVS.py

Summary

Maintainability
F
5 days
Test Coverage

File DEVS.py has 607 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: Latin-1 -*-
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# DEVS.py --- Classes and Tools for DEVS Model Specification
#                     --------------------------------
#                            Copyright (c) 2013
Severity: Major
Found in DEVSKernel/PyPDEVS/old/DEVS.py - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

            if ((p1.hostDEVS.parent == self and p2.hostDEVS.parent == self) and
                    (p1.type() == 'OUTPORT' and p2.type() == 'INPORT')):
                if p1.hostDEVS is p2.hostDEVS:
                    raise DEVSException("In coupled model '%s', connecting ports" +
                                        " '%s' and '%s' belong to the same model" +
    Severity: Critical
    Found in DEVSKernel/PyPDEVS/old/DEVS.py - About 1 hr to fix

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

          def connectPorts(self, p1, p2):
              """
              Connects two ports together. The coupling is to begin at p1 and
              to end at p2.
              """
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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 revert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def revert(self, time):
              """
              Revert the model to the specified time. All necessary cleanup for this
              model will be done (fossil collection).
              Args:
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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 send has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def send(self, msg):
              """
              Send a message to this model, it will actually be redirected to the
              remote model in a way that is transparent to the invoker of the send
              method.
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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 setData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def setData(self):
              """
              Set all data for this model correctly
              """
              if self.IPorts or self.OPorts:
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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 addSubModel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def addSubModel(self, model, location = None, imports = None):
              """
              Adds a specified model to the current coupled model as its child. This
              is the function that must be used to make distributed simulation
              possible.
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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 setGVT has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def setGVT(self, GVT):
              """
              Set the GVT of the model, cleaning up the states vector as required
              for the time warp algorithm
              Args:
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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

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

          def getPortName(self):
              """
              Returns the name of the port
              """
              if self.name is None:
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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

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

          def getPortByName(self, name):
              for i in self.IPorts:
                  if i.getPortName() == name:
                      return i
              for i in self.OPorts:
      Severity: Minor
      Found in DEVSKernel/PyPDEVS/old/DEVS.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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              for i in self.OPorts:
                  print(('\t'*(indent+1) + "OPort " + str(i.getPortFullName())))
                  for j in i.outLine:
                      print(('\t'*(indent+2) + str(j.hostDEVS.getModelFullName())))
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 4 hrs to fix
      DEVSKernel/PyPDEVS/old/DEVS.py on lines 303..306

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              for i in self.OPorts:
                  print(('\t'*(indent+1) + "OPort " + str(i.getPortFullName())))
                  for j in i.outLine:
                      print(('\t'*(indent+2) + str(j.hostDEVS.getModelFullName())))
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 4 hrs to fix
      DEVSKernel/PyPDEVS/old/DEVS.py on lines 617..620

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if ((p1.hostDEVS.parent == self and p2.hostDEVS.parent == self) and
                      (p1.type() == 'OUTPORT' and p2.type() == 'INPORT')):
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 2 hrs to fix
      DEVSKernel/PyPDEVS/pypdevs221/src/DEVS.py on lines 627..628

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 56.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

              elif ((p1.hostDEVS == self and p2.hostDEVS.parent == self) and
                    (p1.type() == p2.type() == 'INPORT')):
                  self.EIC.append( ( (p1.hostDEVS, p1), (p2.hostDEVS, p2) ) )
                  p1.outLine.append(p2)
                  p2.inLine.append(p1)
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 3 other locations - About 1 hr to fix
      DEVSKernel/PyDEVS/DEVS.py on lines 364..367
      DEVSKernel/PyDEVS/DEVS.py on lines 370..373
      DEVSKernel/PyPDEVS/old/DEVS.py on lines 592..596

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

              elif ((p1.hostDEVS.parent == self and p2.hostDEVS == self) and
                    (p1.type() == p2.type() == 'OUTPORT')):
                  self.EOC.append( ( (p1.hostDEVS, p1), (p2.hostDEVS, p2) ) )
                  p1.outLine.append(p2)
                  p2.inLine.append(p1)
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 3 other locations - About 1 hr to fix
      DEVSKernel/PyDEVS/DEVS.py on lines 364..367
      DEVSKernel/PyDEVS/DEVS.py on lines 370..373
      DEVSKernel/PyPDEVS/old/DEVS.py on lines 585..589

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def addInPort(self, name=None):
              """
              Add an input port to the DEVS model.
      
              addInPort and addOutPort are the only proper way to
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 1 hr to fix
      DEVSKernel/PyPDEVS/old/DEVS.py on lines 202..216

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  if p1.hostDEVS is p2.hostDEVS:
                      raise DEVSException("In coupled model '%s', connecting ports" +
                                          " '%s' and '%s' belong to the same model" +
                                          " '%s'. " +
                                          " Direct feedback coupling not allowed" % (
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 1 hr to fix
      DEVSKernel/PyDEVS/DEVS.py on lines 356..361

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def addOutPort(self, name=None):
              """Add an output port to the DEVS model.
      
              See comments for addInPort above.
              Args:
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 1 hr to fix
      DEVSKernel/PyPDEVS/old/DEVS.py on lines 177..200

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 47.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              if self.oldStates == []:
                  pass
              elif copy is None:
                  self.oldStates = [self.oldStates[-1]]
              else:
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 1 hr to fix
      DEVSKernel/PyPDEVS/pypdevs221/src/DEVS.py on lines 241..246

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 43.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def getModelName(self):
              """
              Get the local model name
              """
              if self.name is None:
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 1 hr to fix
      DEVSKernel/PyPDEVS/pypdevs221/src/DEVS.py on lines 157..166

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 40.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def confTransition(self, inputs): # pragma: no cover
              """
              DEFAULT Confluent Transition Function.
      
              Accesses state and elapsed attributes, as well as inputs
      Severity: Major
      Found in DEVSKernel/PyPDEVS/old/DEVS.py and 1 other location - About 1 hr to fix
      DEVSKernel/PyPDEVS/pypdevs221/src/DEVS.py on lines 332..346

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status