cclausen/petri_net

View on GitHub
lib/petri_net/net.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Net has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

class PetriNet::Net < PetriNet::Base
    include LUSolve
    # Human readable name
    attr_accessor :name
    # Storage filename
Severity: Minor
Found in lib/petri_net/net.rb - About 5 hrs to fix

    File net.rb has 347 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'yaml'
    require 'graphviz'
    require 'matrix'
    require 'bigdecimal/ludcmp'
    
    
    Severity: Minor
    Found in lib/petri_net/net.rb - About 4 hrs to fix

      Method coverability_helper has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def coverability_helper(markings, source, added_omega = false)
              @transitions.each_value do |tid|
                  if @objects[tid].fire
                      current_node = PetriNet::ReachabilityGraph::Node.new(@graph, markings: get_markings)
                      current_node_id = @graph.add_node current_node
      Severity: Minor
      Found in lib/petri_net/net.rb - 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

      Method reachability_helper has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def reachability_helper(markings, source)
              @transitions.each_value do |tid|
                  raise PetriNet::ReachabilityGraph::InfinityGraphError if @objects[tid].inputs.empty? && !@objects[tid].outputs.empty?
                  next if @objects[tid].inputs.empty?
                  if @objects[tid].fire
      Severity: Minor
      Found in lib/petri_net/net.rb - 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

      Method get_marking has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_marking(places)
              unless places.class.to_s == "Array"
                  places = [places]
              end
              if places.first.class.to_s == "Fixnum"
      Severity: Minor
      Found in lib/petri_net/net.rb - 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

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

          def add_place(place)
              if place.validate && !@places.include?(place.name) 
                  @places[place.name] = place.id
                  @objects[place.id] = place
                  place.net = self
      Severity: Minor
      Found in lib/petri_net/net.rb and 1 other location - About 30 mins to fix
      lib/petri_net/net.rb on lines 115..123

      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 32.

      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 add_transition(transition)
              if transition.validate && !@transitions.include?(transition.name)
                  @transitions[transition.name] = transition.id
                  @objects[transition.id] = transition
                  transition.net = self
      Severity: Minor
      Found in lib/petri_net/net.rb and 1 other location - About 30 mins to fix
      lib/petri_net/net.rb on lines 84..92

      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 32.

      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 generate_coverability_graph()
              startmarkings = get_markings
              @graph = PetriNet::CoverabilityGraph.new(self)
              @graph.add_node current_node = PetriNet::CoverabilityGraph::Node.new(@graph, markings: get_markings, start: true)
      
      
      Severity: Minor
      Found in lib/petri_net/net.rb and 1 other location - About 20 mins to fix
      lib/petri_net/net.rb on lines 265..273

      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 28.

      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 generate_reachability_graph()
              startmarkings = get_markings
              @graph = PetriNet::ReachabilityGraph.new(self)
              @graph.add_node current_node = PetriNet::ReachabilityGraph::Node.new(@graph, markings: get_markings, start: true)
      
      
      Severity: Minor
      Found in lib/petri_net/net.rb and 1 other location - About 20 mins to fix
      lib/petri_net/net.rb on lines 254..262

      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 28.

      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 to_gv(output = 'png', filename = '')
              g = generate_gv
              if filename.empty?
                  filename = "#{@name}_net.png"
              end
      Severity: Minor
      Found in lib/petri_net/net.rb and 1 other location - About 20 mins to fix
      lib/petri_net/graph/graph.rb on lines 112..118

      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 27.

      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