RailsEventStore/rails_event_store

View on GitHub

Showing 48 of 48 total issues

Method read_scope has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

      def read_scope(spec)
        if spec.stream.global?
          stream = @event_klass
          stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
          stream = stream.where(event_type: spec.with_types) if spec.with_types?

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 event_repository.rb has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module RubyEventStore
  module Sequel
    class EventRepository
      UPSERT_COLUMNS = %i[event_type data metadata valid_at].freeze

    Class Specification has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Specification
        DEFAULT_BATCH_SIZE = 100
    
        # @api private
        # @private
    Severity: Minor
    Found in ruby_event_store/lib/ruby_event_store/specification.rb - About 3 hrs to fix

      Class EventRepository has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class EventRepository
            UPSERT_COLUMNS = %i[event_type data metadata valid_at].freeze
      
            def initialize(sequel:, serializer:)
              @serializer = serializer

        Class EventRepositoryReader has 29 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class EventRepositoryReader
              def initialize(event_klass, stream_klass, serializer)
                @event_klass = event_klass
                @stream_klass = stream_klass
                @serializer = serializer

          Class Client has 28 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Client
              def initialize(
                repository: InMemoryRepository.new,
                mapper: Mappers::Default.new,
                subscriptions: Subscriptions.new,
          Severity: Minor
          Found in ruby_event_store/lib/ruby_event_store/client.rb - About 3 hrs to fix

            Class SpecificationResult has 28 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class SpecificationResult
                def initialize(
                  direction: :forward,
                  start: nil,
                  stop: nil,
            Severity: Minor
            Found in ruby_event_store/lib/ruby_event_store/specification_result.rb - About 3 hrs to fix

              Method read_scope has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

                      def read_scope(specification)
                        direction = specification.forward? ? :forward : :backward
              
                        if specification.last? && !specification.start && !specification.stop
                          direction = specification.forward? ? :backward : :forward

              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

              Class InMemoryRepository has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class InMemoryRepository
                  class UnsupportedVersionAnyUsage < StandardError
                    def initialize
                      super <<~EOS
                      Mixing expected version :any and specific position (or :auto) is unsupported.
              Severity: Minor
              Found in ruby_event_store/lib/ruby_event_store/in_memory_repository.rb - About 3 hrs to fix

                Method read_from_global_stream has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                      def read_from_global_stream(specification)
                        dataset =
                          @db[:event_store_events]
                            .select(
                              ::Sequel[:event_store_events][:event_id],

                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

                Class EventRepository has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class EventRepository
                      POSITION_SHIFT = 1
                
                      def initialize(model_factory: WithDefaultModels.new, serializer:)
                        @serializer = serializer

                  Method read_from_specific_stream has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def read_from_specific_stream(specification)
                          dataset =
                            @db[:event_store_events]
                              .join(:event_store_events_in_streams, event_id: :event_id)
                              .select(

                  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 failure_message has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def failure_message(expected, events, stream_name = nil)
                            return failure_message_strict(expected, events) if expected.strict?
                            return failure_message_no_events if expected.empty?
                            expected.events.each do |expected_event|
                              correct_event_count = 0

                  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 parse has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def self.parse(argv)
                            options = Options.new(*DEFAULTS.values)
                            OptionParser
                              .new do |option_parser|
                                option_parser.banner = "Usage: res_outbox [options]"
                  Severity: Major
                  Found in contrib/ruby_event_store-outbox/lib/ruby_event_store/outbox/cli.rb - About 2 hrs to fix

                    Method read_from_specific_stream has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def read_from_specific_stream(specification)
                            dataset =
                              @db[:event_store_events]
                                .join(:event_store_events_in_streams, event_id: :event_id)
                                .select(

                      Method read has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def read(specification, serializer)
                                query = read_scope(specification)
                      
                                if specification.batched?
                                  BatchEnumerator.new(

                      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 read_from_global_stream has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def read_from_global_stream(specification)
                              dataset =
                                @db[:event_store_events]
                                  .select(
                                    ::Sequel[:event_store_events][:event_id],

                        Method call has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def call(env)
                                router = Router.new(routing)
                                router.add_route("GET", "/api/events/:event_id") do |params|
                                  json GetEvent.new(event_store: event_store, event_id: params.fetch("event_id"))
                                end
                        Severity: Minor
                        Found in ruby_event_store-browser/lib/ruby_event_store/browser/app.rb - About 1 hr to fix

                          Method for has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def self.for(
                                  event_store_locator:,
                                  host: nil,
                                  path: nil,
                                  api_url: nil,
                          Severity: Minor
                          Found in ruby_event_store-browser/lib/ruby_event_store/browser/app.rb - About 1 hr to fix

                            Method append_to_stream has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                                  def append_to_stream(records, stream, expected_version)
                                    resolved_version = resolved_version(expected_version, stream)
                            
                                    @db.transaction do
                                      records.map.with_index do |record, index|

                            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