ideasasylum/deepstate

View on GitHub

Showing 6 of 6 total issues

Class StateDefinition has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class StateDefinition
    attr_reader :name, :type, :events, :states,
      :initial_state, :terminal_state, :parent_state

    def initialize name, parent_state = nil, type: :state
Severity: Minor
Found in lib/deep_state/state_definition.rb - About 2 hrs to fix

    Method visit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def visit state
          # binding.pry if state.name == :assigned
          @states << state
          @initial_states << state if state.initial?
          @terminal_states << state if state.terminal?
    Severity: Minor
    Found in lib/deep_state/dot_visitor.rb - 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

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize name, from_state, to_state, conditions={}, &block
    Severity: Minor
    Found in lib/deep_state/event.rb - About 35 mins to fix

      Method visit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def visit state
            @states << state
      
            # Create the path of the parent nodes
            path = []
      Severity: Minor
      Found in lib/deep_state/xstate_visitor.rb - 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

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

          def transition event_name
            event = transitions.find { |t| t.name == event_name }
            raise DeepState::Error unless event
      
            return unless event.run?(context)
      Severity: Minor
      Found in lib/deep_state/state_machine.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

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

          def parents include_root: false
            Enumerator.new do |yielder|
              # Walk up the parent states, excluding the very root state
              p = parent_state
              while p
      Severity: Minor
      Found in lib/deep_state/state_definition.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

      Severity
      Category
      Status
      Source
      Language