RailsEventStore/rails_event_store

View on GitHub

Showing 48 of 48 total issues

Method link_to_stream has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def link_to_stream(event_ids, stream, expected_version)
      serialized_records = event_ids.map { |id| read_event(id) }

      with_synchronize(expected_version, stream) do |resolved_version|
        ensure_supported_any_usage(resolved_version, stream)
Severity: Minor
Found in ruby_event_store/lib/ruby_event_store/in_memory_repository.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 ensure_supported_any_usage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def ensure_supported_any_usage(resolved_version, stream)
      if @ensure_supported_any_usage
        stream_positions = streams.fetch(stream.name, Array.new).map(&:position)
        if resolved_version.nil?
          raise UnsupportedVersionAnyUsage if !stream_positions.compact.empty?
Severity: Minor
Found in ruby_event_store/lib/ruby_event_store/in_memory_repository.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 encryption_metadata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def encryption_metadata(data, schema)
          schema.inject({}) do |acc, (key, value)|
            case value
            when Hash
              acc[key] = encryption_metadata(data, value)

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

    def each
      return to_enum unless block_given?

      0.step(total_limit - 1, batch_size) do |batch_offset|
        batch_limit = [batch_size, total_limit - batch_offset].min
Severity: Minor
Found in ruby_event_store/lib/ruby_event_store/batch_enumerator.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 append_to_stream has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def append_to_stream(records, stream, expected_version)
      serialized_records = records.map { |record| record.serialize(serializer) }

      with_synchronize(expected_version, stream) do |resolved_version|
        ensure_supported_any_usage(resolved_version, stream)
Severity: Minor
Found in ruby_event_store/lib/ruby_event_store/in_memory_repository.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 monotonic_id_batch_reader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def monotonic_id_batch_reader(spec, stream)
        batch_reader = ->(offset_id, limit) do
          search_in = spec.stream.global? ? @event_klass.table_name : @stream_klass.table_name
          records =
            if offset_id.nil?

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

        def ordered(direction, stream, offset_entry_id = nil, stop_entry_id = nil, time_sort_by = nil)
          order, operator_offset, operator_stop = DIRECTION_MAP[direction]

          raise ArgumentError, "Direction must be :forward or :backward" if order.nil?

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

    def events(after_event_id:)
      uri = @uri.dup
      uri.query = URI.encode_www_form({ after_event_id: after_event_id }) if after_event_id

      req = Net::HTTP::Get.new(uri)
Severity: Minor
Found in contrib/dres_client/lib/dres_client.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

Severity
Category
Status
Source
Language