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 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
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],
- Read upRead up
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_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(
- Read upRead up
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_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_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 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|
- Read upRead up
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 append_to_stream
has 26 lines of code (exceeds 25 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|
Method link_to_stream
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def link_to_stream(event_ids, stream, expected_version)
(
event_ids -
@db[:event_store_events]
.select(::Sequel[:event_store_events][:event_id])
- Read upRead up
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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def read(specification)
if specification.batched?
stream = read_(specification)
batch_reader = ->(offset, limit) { stream.offset(offset).limit(limit).map(&method(:record)) }
RubyEventStore::BatchEnumerator.new(specification.batch_size, specification.limit, batch_reader).each
- Read upRead up
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"