arkency/rails_event_store

View on GitHub
ruby_event_store/lib/ruby_event_store/in_memory_repository.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

        def read_scope(spec)
          serialized_records = serialized_records_of_stream(spec.stream)
          serialized_records = ordered(serialized_records, spec)
          serialized_records = serialized_records.select { |e| spec.with_ids.any? { |x| x.eql?(e.event_id) } } if spec
            .with_ids?
    Severity: Minor
    Found in ruby_event_store/lib/ruby_event_store/in_memory_repository.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 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 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

    There are no issues that match your filters.

    Category
    Status