zilverline/sequent

View on GitHub
lib/sequent/migrations/view_schema.rb

Summary

Maintainability
C
1 day
Test Coverage

File view_schema.rb has 307 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'parallel'
require 'postgresql_cursor'

require_relative 'errors'
require_relative '../support/database'
Severity: Minor
Found in lib/sequent/migrations/view_schema.rb - About 3 hrs to fix

    Class ViewSchema has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class ViewSchema
          # Corresponds with the index on aggregate_id column in the event_records table
          #
          # Since we replay in batches of the first 3 chars of the uuid we created an index on
          # these 3 characters. Hence the name ;-)
    Severity: Minor
    Found in lib/sequent/migrations/view_schema.rb - About 3 hrs to fix

      Method replay! has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def replay!(
              replay_persistor,
              groups:,
              projectors: plan.projectors,
              minimum_xact_id_inclusive: nil,
      Severity: Minor
      Found in lib/sequent/migrations/view_schema.rb - About 1 hr to fix

        Method migrate_online has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def migrate_online
                ensure_valid_plan!
                migrate_metadata_tables
        
                return if Sequent.new_version == current_version
        Severity: Minor
        Found in lib/sequent/migrations/view_schema.rb - About 1 hr to fix

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

                def replay!(
                  replay_persistor,
                  groups:,
                  projectors: plan.projectors,
                  minimum_xact_id_inclusive: nil,
          Severity: Minor
          Found in lib/sequent/migrations/view_schema.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 replay_events has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Wontfix

                  aggregate_prefixes,
                  event_types,
                  minimum_xact_id_inclusive,
                  maximum_xact_id_exclusive,
                  replay_persistor,
          Severity: Minor
          Found in lib/sequent/migrations/view_schema.rb - About 45 mins to fix

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

                  def event_stream(aggregate_prefixes, event_types, minimum_xact_id_inclusive, maximum_xact_id_exclusive)
                    fail ArgumentError, 'aggregate_prefixes is mandatory' unless aggregate_prefixes.present?
            
                    event_stream = Sequent.configuration.event_record_class.where(event_type: event_types)
                    event_stream = event_stream.where(<<~SQL, aggregate_prefixes)
            Severity: Minor
            Found in lib/sequent/migrations/view_schema.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