gocardless/statesman

View on GitHub
lib/statesman/adapters/active_record.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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 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 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

      There are no issues that match your filters.

      Category
      Status