state-machines/state_machines

View on GitHub
lib/state_machines/transition.rb

Summary

Maintainability
C
1 day
Test Coverage

Method before has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def before(complete = true, index = 0, &block)
        unless @before_run
          while callback = machine.callbacks[:before][index]
            index += 1
            
Severity: Minor
Found in lib/state_machines/transition.rb - 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

Class Transition has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Transition
    # The object being transitioned
    attr_reader :object
    
    # The state machine for which this transition is defined
Severity: Minor
Found in lib/state_machines/transition.rb - About 3 hrs to fix

    Method after has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def after
            unless @after_run
              # First resume previously paused callbacks
              if resume
                catch(:halt) do
    Severity: Minor
    Found in lib/state_machines/transition.rb - About 55 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 deeply nested control flow statements.
    Open

                      pause if @success && !complete
    Severity: Major
    Found in lib/state_machines/transition.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                        throw :cancel, true unless @success
      Severity: Major
      Found in lib/state_machines/transition.rb - About 45 mins to fix

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

            def initialize(object, machine, event, from_name, to_name, read_state = true) #:nodoc:
        Severity: Minor
        Found in lib/state_machines/transition.rb - About 45 mins to fix

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

                def pause
                  raise ArgumentError, 'around_transition callbacks cannot be called in multiple execution contexts in java implementations of Ruby. Use before/after_transitions instead.' unless self.class.pause_supported?
                  
                  unless @resume_block
                    require 'continuation' unless defined?(callcc)
          Severity: Minor
          Found in lib/state_machines/transition.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 pausable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def pausable
                  begin
                    halted = !catch(:halt) { yield; true }
                  rescue => error
                    raise unless @resume_block
          Severity: Minor
          Found in lib/state_machines/transition.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

          There are no issues that match your filters.

          Category
          Status