piotrmurach/finite_machine

View on GitHub
lib/finite_machine/state_machine.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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

  class StateMachine
    include Threadable
    include Catchable
    extend Forwardable

Severity: Minor
Found in lib/finite_machine/state_machine.rb - About 2 hrs to fix

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

        def trigger!(event_name, *data, &block)
          from = current # Save away current state
    
          sync_exclusive do
            notify HookEvent::Before, event_name, from, *data
    Severity: Minor
    Found in lib/finite_machine/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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(*args, &block)
          options = args.last.is_a?(::Hash) ? args.pop : {}
          @initial_state = DEFAULT_STATE
          @auto_methods  = options.fetch(:auto_methods, true)
          @subscribers   = Subscribers.new
    Severity: Minor
    Found in lib/finite_machine/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

    There are no issues that match your filters.

    Category
    Status