Showing 19 of 29 total issues

Class Base has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Base

    attr_reader :klass, :state_machine

    def initialize(klass, name, state_machine, options={}, &block)
Severity: Minor
Found in lib/aasm/base.rb - About 3 hrs to fix

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

        def _fire(obj, options={}, to_state=::AASM::NO_VALUE, *args)
          result = options[:test_only] ? false : nil
          clear_failed_callbacks
          transitions = @transitions.select { |t| t.from == obj.aasm(state_machine.name).current_state || t.from == nil}
          return result if transitions.size == 0
    Severity: Minor
    Found in lib/aasm/core/event.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 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 states has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def states(options={}, *args)
            if options.has_key?(:permitted)
              selected_events = events({:permitted => options[:permitted]}, *args)
              # An array of arrays. Each inner array represents the transitions that
              # transition from the current state for an event
      Severity: Minor
      Found in lib/aasm/instance_base.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 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 state has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def state(*args)
            names, options = interpret_state_args(args)
            names.each do |name|
              @state_machine.add_state(name, klass, options)
      
      
      Severity: Minor
      Found in lib/aasm/base.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

      Method load_persistence has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_persistence(base)
              # Use a fancier auto-loading thingy, perhaps.  When there are more persistence engines.
              hierarchy = base.ancestors.map {|klass| klass.to_s}
      
              if hierarchy.include?("ActiveRecord::Base")
      Severity: Minor
      Found in lib/aasm/persistence.rb - About 45 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 aasm_ensure_initial_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def aasm_ensure_initial_state
                AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |state_machine_name|
                  attribute_name = self.class.aasm(state_machine_name).attribute_name.to_s
                  # Do not load initial state when object attributes are not loaded,
                  # mongoid has_many relationship does not load child object attributes when
      Severity: Minor
      Found in lib/aasm/persistence/mongoid_persistence.rb - About 45 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 register has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def register(name, machine, force = false)
            raise "Cannot use #{name.inspect} for machine name" unless name.is_a?(Symbol) or name.is_a?(String)
            raise "Cannot use #{machine.inspect} as a machine" unless machine.is_a?(AASM::StateMachine)
      
            if force
      Severity: Minor
      Found in lib/aasm/state_machine_store.rb - About 45 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 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(klass, name, state_machine, options={}, &block)
        Severity: Minor
        Found in lib/aasm/base.rb - About 35 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 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def aasm_fire_event(state_machine_name, name, options, *args, &block)
            Severity: Minor
            Found in lib/aasm/persistence/orm.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, name, options, *args, &block)
                      return super unless aasm_supports_transactions? && options[:persist]
              
                      event = self.class.aasm(state_machine_name).state_machine.events[name]
                      event.fire_callbacks(:before_transaction, self, *args)
              Severity: Minor
              Found in lib/aasm/persistence/orm.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 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

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

                      def aasm_transaction(requires_new, requires_lock)
                        self.class.db.transaction(savepoint: requires_new) do
                          if requires_lock
                            # http://sequel.jeremyevans.net/rdoc/classes/Sequel/Model/InstanceMethods.html#method-i-lock-21
                            requires_lock.is_a?(String) ? lock!(requires_lock) : lock!
              Severity: Minor
              Found in lib/aasm/persistence/sequel_persistence.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 aasm_read_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def aasm_read_state(name=:default)
                      state = send(self.class.aasm(name).attribute_name)
                      if !state || state.empty?
                        aasm_new_record? ? aasm(name).determine_state_name(self.class.aasm(name).initial_state) : nil
                      else
              Severity: Minor
              Found in lib/aasm/persistence/base.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 aasm_write_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def aasm_write_state(state, name=:default)
                      attribute_name = self.class.aasm(name).attribute_name
                      old_value = aasm_read_attribute(attribute_name)
                      aasm_write_state_attribute state, name
              
              
              Severity: Minor
              Found in lib/aasm/persistence/orm.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