gocardless/statesman

View on GitHub

Showing 7 of 7 total issues

Class ActiveRecord has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

    class ActiveRecord
      JSON_COLUMN_TYPES = %w[json jsonb].freeze

      def self.database_supports_partial_indexes?(model)
        # Rails 3 doesn't implement `supports_partial_index?`
Severity: Minor
Found in lib/statesman/adapters/active_record.rb - About 4 hrs to fix

    File machine.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative "version"
    require_relative "exceptions"
    require_relative "guard"
    require_relative "callback"
    require_relative "adapters/memory_transition"
    Severity: Minor
    Found in lib/statesman/machine.rb - About 2 hrs to fix

      File active_record.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_relative "../exceptions"
      
      module Statesman
        module Adapters
          class ActiveRecord
      Severity: Minor
      Found in lib/statesman/adapters/active_record.rb - About 2 hrs to fix

        Method filter_callbacks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def filter_callbacks(callbacks, from: nil, to: nil)
                callbacks.filter_map do |callback|
                  next if callback.from == from && to.nil?
        
                  if callback.to.include?(to) && (from.nil? || callback.from == from)
        Severity: Minor
        Found in lib/statesman/machine.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 remove_transitions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def remove_transitions(from: nil, to: nil)
                raise ArgumentError, "Both from and to can't be nil!" if from.nil? && to.nil?
                return if successors.nil?
        
                if from.present?
        Severity: Minor
        Found in lib/statesman/machine.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 create_transition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_transition(from, to, metadata)
                transition = transitions_for_parent.build(
                  default_transition_attributes(to, metadata),
                )
        
        
        Severity: Minor
        Found in lib/statesman/adapters/active_record.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 not_most_recent_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def not_most_recent_value(db_cast: true)
                if transition_class.columns_hash["most_recent"].null == false
                  return db_cast ? db_false : false
                end
        
        
        Severity: Minor
        Found in lib/statesman/adapters/active_record.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