arkency/rails_event_store

View on GitHub

Showing 76 of 76 total issues

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

  module Mappers
    module Transformation
      class StringifyMetadataKeys
        def dump(record)
          stringify(record)
ruby_event_store/lib/ruby_event_store/mappers/transformation/symbolize_metadata_keys.rb on lines 4..25

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

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

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

  module Mappers
    module Transformation
      class SymbolizeMetadataKeys
        def dump(record)
          symbolize(record)
ruby_event_store/lib/ruby_event_store/mappers/transformation/stringify_metadata_keys.rb on lines 4..25

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

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

Method call has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def call(_name, _start, _finish, _id, payload)
Severity: Minor
Found in contrib/ruby_event_store-flipper/lib/ruby_event_store/flipper.rb - About 35 mins to fix

    Method ordered has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def ordered(direction, stream, offset_entry_id = nil, stop_entry_id = nil, time_sort_by = nil)

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                def initialize(actual_klass, actual_metadata, actual_data, expected_metadata, expected_data)
      Severity: Minor
      Found in ruby_event_store-rspec/lib/ruby_event_store/rspec/be_event.rb - About 35 mins to fix

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

            def ==(other)
              other.instance_of?(self.class) && other.event_id.eql?(event_id) && other.data.eql?(data) &&
                other.metadata.eql?(metadata) && other.event_type.eql?(event_type) && other.timestamp.eql?(timestamp) &&
                other.valid_at.eql?(valid_at)
            end
        Severity: Minor
        Found in ruby_event_store/lib/ruby_event_store/serialized_record.rb and 1 other location - About 35 mins to fix
        ruby_event_store/lib/ruby_event_store/record.rb on lines 24..28

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

        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

            def ==(other)
              other.instance_of?(self.class) && other.event_id.eql?(event_id) && other.data.eql?(data) &&
                other.metadata.eql?(metadata) && other.event_type.eql?(event_type) && other.timestamp.eql?(timestamp) &&
                other.valid_at.eql?(valid_at)
            end
        Severity: Minor
        Found in ruby_event_store/lib/ruby_event_store/record.rb and 1 other location - About 35 mins to fix
        ruby_event_store/lib/ruby_event_store/serialized_record.rb on lines 23..27

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

        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

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

              def each
                return to_enum unless block_given?
                offset_id = nil
        
                0.step(total_limit - 1, batch_size) do |batch_offset|

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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                def older_than_or_equal(time, time_sort_by)
                  if time_sort_by == :as_of
                    join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) <= time.localtime }
                  else
                    join_events.where { |r| r.events[:created_at] <= time.localtime }
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 37..41
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 45..49
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 53..57

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

        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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                def newer_than(time, time_sort_by)
                  if time_sort_by == :as_of
                    join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) > time.localtime }
                  else
                    join_events.where { |r| r.events[:created_at] > time.localtime }
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 45..49
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 53..57
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 61..65

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

        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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                def older_than(time, time_sort_by)
                  if time_sort_by == :as_of
                    join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) < time.localtime }
                  else
                    join_events.where { |r| r.events[:created_at] < time.localtime }
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 37..41
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 45..49
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 61..65

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

        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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                def newer_than_or_equal(time, time_sort_by)
                  if time_sort_by == :as_of
                    join_events.where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) >= time.localtime }
                  else
                    join_events.where { |r| r.events[:created_at] >= time.localtime }
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 37..41
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 53..57
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/stream_entries.rb on lines 61..65

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

        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

                map do
                  rename_keys timestamp: :created_at
                  map_value :created_at, ->(time) { Time.iso8601(time).localtime }
                  map_value :valid_at, ->(time) { Time.iso8601(time).localtime }
                  accept_keys %i[event_id data metadata event_type created_at valid_at]
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/changesets/create_events.rb on lines 10..14

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

        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

                map do
                  rename_keys timestamp: :created_at
                  map_value :created_at, ->(time) { Time.iso8601(time).localtime }
                  map_value :valid_at, ->(time) { Time.iso8601(time).localtime }
                  accept_keys %i[event_id data metadata event_type created_at valid_at]
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/changesets/update_events.rb on lines 10..14

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

        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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                def newer_than_or_equal(time, time_sort_by)
                  if time_sort_by == :as_of
                    where { |r| string::coalesce(r.events[:valid_at], r.events[:created_at]) >= time.localtime }
                  else
                    where { |r| r.events[:created_at] >= time.localtime }
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/events.rb on lines 37..41
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/events.rb on lines 53..57
        contrib/ruby_event_store-rom/lib/ruby_event_store/rom/relations/events.rb on lines 61..65

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

        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