zeto/control

View on GitHub

Showing 4 of 4 total issues

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

    def validate_transition
      raise Control::NoAssociationToWorkflow unless is_part_of_workflow?
      raise Control::WorkflowDisabled unless workflow.enabled
      raise Control::InvalidTransition unless workflow_initial_state_or_valid_next_state
      raise Control::FinalState if current_state_is_final?
Severity: Minor
Found in lib/control/state.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 next_states has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def next_states(*states)
        if states.any?
          if states.include? :none
            @final = true
          else
Severity: Minor
Found in lib/control/state.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 workflow_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def workflow_class
        unless @workflow_class
          reflect_on_all_associations.each do |a|
            klass = a.klass
            @workflow_class = klass if klass.respond_to?(:is_workflow?) && klass.is_workflow?
Severity: Minor
Found in lib/control/state.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 validate_classes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_classes
      Kernel.qualified_const_get(from_class) unless from_class.blank? rescue errors.add(:from_class,'invalid from')
      Kernel.qualified_const_get(to_class) rescue errors.add(:to_class,'invalid to')
      Kernel.qualified_const_get(workflow_class) rescue errors.add(:workflow_class,'invalid workflow')
    end
Severity: Minor
Found in lib/control/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

Severity
Category
Status
Source
Language