zilverline/sequent

View on GitHub

Showing 34 of 47 total issues

Method register_tasks! has 188 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def register_tasks!
        namespace :sequent do
          desc <<~EOS
            Set the SEQUENT_ENV to RAILS_ENV or RACK_ENV if not already set
          EOS
Severity: Major
Found in lib/sequent/rake/migration_tasks.rb - About 7 hrs to fix

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

          def register_tasks!
            namespace :sequent do
              desc <<~EOS
                Set the SEQUENT_ENV to RAILS_ENV or RACK_ENV if not already set
              EOS
    Severity: Minor
    Found in lib/sequent/rake/migration_tasks.rb - About 6 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

    File view_schema.rb has 308 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

        File replay_optimized_postgres_persistor.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'set'
        require 'active_record'
        require 'csv'
        require_relative './persistor'
        
        
        Severity: Minor
        Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.rb - About 2 hrs to fix

          Class ReplayOptimizedPostgresPersistor has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

                class ReplayOptimizedPostgresPersistor
                  include Persistor
                  CHUNK_SIZE = 1024
          
                  attr_reader :record_store
          Severity: Minor
          Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.rb - About 2 hrs to fix

            Method from_params has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                    def from_params(params, strict_nil_check = true)
                      params = HashWithIndifferentAccess.new(params)
                      self.class.types.each do |attribute, type|
                        value = params[attribute]
            
            
            Severity: Minor
            Found in lib/sequent/core/helpers/param_support.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 commit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def commit
                      @record_store.each do |clazz, records|
                        @column_cache ||= {}
                        @column_cache[clazz.name] ||= clazz.columns.reduce({}) do |hash, column|
                          hash.merge({column.name => column})
            Severity: Minor
            Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.rb - About 1 hr to fix

              Method map_to_migrations has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                    def map_to_migrations(migrations)
                      migrations.reduce({}) do |memo, (version, ms)|
                        unless ms.is_a?(Array)
                          fail InvalidMigrationDefinition,
                               "Declared migrations for version #{version} must be an Array. For example: {'3' => [FooProjector]}"
              Severity: Minor
              Found in lib/sequent/migrations/planner.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 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 process_event has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                        def process_event(event)
                          [*Sequent::Core::Workflow.descendants, *Sequent::Core::Projector.descendants].each do |handler_class|
                            next unless handler_class.handles_message?(event)
                
                            if handler_class < Sequent::Workflow
                Severity: Minor
                Found in lib/sequent/util/dry_run.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 initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize
                      self.command_handlers = []
                      self.command_filters = []
                      self.event_handlers = []
                      self.command_middleware = Sequent::Core::Middleware::Chain.new
                Severity: Minor
                Found in lib/sequent/configuration.rb - About 1 hr to fix

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

                          def validate(record)
                            associations = options[:associations]
                            associations = [associations] unless associations.instance_of?(Array)
                            associations.each do |association|
                              value = record.instance_variable_get("@#{association}")
                  Severity: Minor
                  Found in lib/sequent/core/helpers/association_validator.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 == has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def ==(other)
                            return false if other.nil?
                            return false if self.class != other.class
                  
                            self.class.types.each do |name, _|
                  Severity: Minor
                  Found in lib/sequent/core/helpers/equal_support.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 migrate_online has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Method attrs has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                              def attrs(args)
                                validate_attrs!(args)
                    
                                @types.merge!(args)
                                associations = []
                    Severity: Minor
                    Found in lib/sequent/core/helpers/attribute_support.rb - About 1 hr to fix

                      Method commit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def commit
                                @record_store.each do |clazz, records|
                                  @column_cache ||= {}
                                  @column_cache[clazz.name] ||= clazz.columns.reduce({}) do |hash, column|
                                    hash.merge({column.name => column})
                      Severity: Minor
                      Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.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 as_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def as_params
                                hash = HashWithIndifferentAccess.new
                                self.class.types.each do |field|
                                  value = instance_variable_get("@#{field[0]}")
                                  next if field[0] == 'errors'
                      Severity: Minor
                      Found in lib/sequent/core/helpers/param_support.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 autoregister! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def autoregister!
                            return unless enable_autoregistration
                      
                            # Only autoregister the AggregateSnapshotter if the autoregistration is enabled
                            Sequent::Core::AggregateSnapshotter.skip_autoregister = false
                      Severity: Minor
                      Found in lib/sequent/configuration.rb - About 1 hr to fix

                        Method store_events has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def store_events(command, streams_with_events = [])
                                command_record = CommandRecord.create!(command: command)
                                event_records = streams_with_events.flat_map do |event_stream, uncommitted_events|
                                  unless event_stream.stream_record_id
                                    stream_record = Sequent.configuration.stream_record_class.new
                        Severity: Minor
                        Found in lib/sequent/core/event_store.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language