lib/aasm/aasm.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method aasm_fired has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def aasm_fired(state_machine_name, event, old_state, new_state_name, options, *args)
    persist = options[:persist]

    new_state = aasm(state_machine_name).state_object_for_name(new_state_name)
    callback_args = process_args(event, aasm(state_machine_name).current_state, *args)
Severity: Minor
Found in lib/aasm/aasm.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 aasm_fired has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def aasm_fired(state_machine_name, event, old_state, new_state_name, options, *args)
    persist = options[:persist]

    new_state = aasm(state_machine_name).state_object_for_name(new_state_name)
    callback_args = process_args(event, aasm(state_machine_name).current_state, *args)
Severity: Minor
Found in lib/aasm/aasm.rb - About 1 hr to fix

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

        def aasm(*args, &block)
          if args[0].is_a?(Symbol) || args[0].is_a?(String)
            # using custom name
            state_machine_name = args[0].to_sym
            options = args[1] || {}
    Severity: Minor
    Found in lib/aasm/aasm.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 aasm_fired has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def aasm_fired(state_machine_name, event, old_state, new_state_name, options, *args)
    Severity: Minor
    Found in lib/aasm/aasm.rb - About 45 mins to fix

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

        def aasm_fire_event(state_machine_name, event_name, options, *args, &block)
      Severity: Minor
      Found in lib/aasm/aasm.rb - About 35 mins to fix

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

          def aasm_fire_event(state_machine_name, event_name, options, *args, &block)
            event = self.class.aasm(state_machine_name).state_machine.events[event_name]
            begin
              old_state = aasm(state_machine_name).state_object_for_name(aasm(state_machine_name).current_state)
        
        
        Severity: Minor
        Found in lib/aasm/aasm.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

        There are no issues that match your filters.

        Category
        Status