arkency/rails_event_store

View on GitHub

Showing 76 of 76 total issues

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

    Method handle_split has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def handle_split(fetch_specification)
            obtained_lock = obtain_lock_for_process(fetch_specification)
            return false unless obtained_lock
    
            something_processed = false

      Method build_domain_event has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build_domain_event(common_payload, operation, payload)
              case operation
              when :add
                event_klass("ToggleAdded").new(data: common_payload)
              when :remove
      Severity: Minor
      Found in contrib/ruby_event_store-flipper/lib/ruby_event_store/flipper.rb - About 1 hr to fix

        Method initialize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(
              direction: :forward,
              start: nil,
              stop: nil,
              older_than: nil,
        Severity: Minor
        Found in ruby_event_store/lib/ruby_event_store/specification_result.rb - About 1 hr to fix

          Method failure_message has 34 lines of code (exceeds 25 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

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

                  def handle_split(fetch_specification)
                    obtained_lock = obtain_lock_for_process(fetch_specification)
                    return false unless obtained_lock
            
                    something_processed = false

            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 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def read(spec)
                    stream = read_scope(spec)
                    if spec.batched?
                      spec.time_sort_by ? offset_limit_batch_reader(spec, stream) : monotonic_id_batch_reader(spec, stream)
                    elsif spec.first?

            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_scope has 30 lines of code (exceeds 25 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

              Method read_scope has 30 lines of code (exceeds 25 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?

                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 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 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

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

                        def add_to_stream(event_ids, stream, expected_version)
                          last_stream_version = ->(stream_) do
                            @stream_klass.where(stream: stream_.name).order("position DESC").first.try(:position)
                          end
                          resolved_version = expected_version.resolve_for(stream, last_stream_version)

                  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 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])

                  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 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                            expected_klass,
                            actual_klass,
                            expected_data,
                            actual_data,
                            expected_metadata,
                  Severity: Minor
                  Found in ruby_event_store-rspec/lib/ruby_event_store/rspec/be_event.rb - About 45 mins to fix

                    Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def initialize(url: nil, **kwargs)
                                return super unless url
                    
                                uri = URI.parse(url)
                                if uri.scheme == "unix"
                    Severity: Minor
                    Found in support/helpers/redis_client_unix_socket_patch.rb - About 45 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 decrypt_attribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def decrypt_attribute(data, attribute, meta)
                              case meta
                              when Leaf
                                cryptogram = data.fetch(attribute)
                                return unless cryptogram

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                      module Flipper
                        module Events
                          class ToggleAdded < RubyEventStore::Event
                          end
                    
                    
                    contrib/ruby_event_store-flipper/lib/generators/ruby_event_store/flipper/templates/events.rb on lines 4..40

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 38.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                      module Flipper
                        module Events
                          class ToggleAdded < RubyEventStore::Event
                          end
                    
                    
                    contrib/ruby_event_store-flipper/lib/ruby_event_store/flipper/events.rb on lines 4..40

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 38.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language