zilverline/sequent

View on GitHub

Showing 46 of 47 total issues

Method autoregister! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def autoregister!
      return unless enable_autoregistration

      # Only autoregister the AggregateSnapshotter if the autoregistration is enabled
      Sequent::Core::AggregateSnapshotter.skip_autoregister = false
Severity: Minor
Found in lib/sequent/configuration.rb - About 1 hr to fix

    Method store_events has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def store_events(command, streams_with_events = [])
            command_record = CommandRecord.create!(command: command)
            event_records = streams_with_events.flat_map do |event_stream, uncommitted_events|
              unless event_stream.stream_record_id
                stream_record = Sequent.configuration.stream_record_class.new
    Severity: Minor
    Found in lib/sequent/core/event_store.rb - About 1 hr to fix

      Method start_offline! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.start_offline!(new_version)
              current_migration = find_by(version: new_version)
              fail MigrationNotStarted if current_migration.blank?
      
              current_migration.with_lock('FOR UPDATE NOWAIT') do
      Severity: Minor
      Found in lib/sequent/migrations/versions.rb - About 55 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 parse_attrs_to_correct_types has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def parse_attrs_to_correct_types
                the_copy = dup
                the_copy.class.types.each do |name, type|
                  raw_value = the_copy.send(name.to_s)
                  next if raw_value.nil?
      Severity: Minor
      Found in lib/sequent/core/helpers/type_conversion_support.rb - About 55 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 load_aggregates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_aggregates(aggregate_ids, clazz = nil)
              fail ArgumentError, 'aggregate_ids is required' unless aggregate_ids
              return [] if aggregate_ids.empty?
      
              unique_ids = aggregate_ids.uniq
      Severity: Minor
      Found in lib/sequent/core/aggregate_repository.rb - About 55 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 2 locations. Consider refactoring.
      Open

            def replace_template_aggregate
              files = Dir["#{path}/**/*"].select { |f| File.file?(f) }
      
              files.each do |filename|
                contents = File.read(filename)
      Severity: Minor
      Found in lib/sequent/generator/aggregate.rb and 1 other location - About 45 mins to fix
      lib/sequent/generator/project.rb on lines 42..49

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

      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

            def replace_app_name
              files = Dir["#{path}/**/*"].select { |f| File.file?(f) }
      
              files.each do |filename|
                contents = File.read(filename)
      Severity: Minor
      Found in lib/sequent/generator/project.rb and 1 other location - About 45 mins to fix
      lib/sequent/generator/aggregate.rb on lines 47..54

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

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

          def autoregister!
            return unless enable_autoregistration
      
            # Only autoregister the AggregateSnapshotter if the autoregistration is enabled
            Sequent::Core::AggregateSnapshotter.skip_autoregister = false
      Severity: Minor
      Found in lib/sequent/configuration.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 replay! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def replay!(
              replay_persistor,
              groups:,
              projectors: plan.projectors,
              minimum_xact_id_inclusive: nil,
      Severity: Minor
      Found in lib/sequent/migrations/view_schema.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 attrs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

                def attrs(args)
                  validate_attrs!(args)
      
                  @types.merge!(args)
                  associations = []
      Severity: Minor
      Found in lib/sequent/core/helpers/attribute_support.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 deserialize_from_json has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.deserialize_from_json(value)
          value.blank? ? nil : Time.iso8601(value.dup)
        rescue ArgumentError => e
          return Time.parse(value.dup) if e.message =~ /invalid xmlschema format/ # ruby >= 3
          return Time.parse(value.dup) if e.message =~ /invalid date:/ # ruby 2.7
      Severity: Minor
      Found in lib/sequent/core/ext/ext.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 find_records has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def find_records(record_class, where_clause)
                where_clause = where_clause.symbolize_keys
      
                indexed_columns = @record_index[record_class].indexed_columns
                indexed_fields, non_indexed_fields = where_clause.partition { |field, _| indexed_columns.include? field }
      Severity: Minor
      Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.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 update_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def update_record(record_class, event, where_clause = {aggregate_id: event.aggregate_id}, options = {})
                record = record_class.unscoped.where(where_clause).first
                unless record
                  fail(<<~EOS)
                    Record of class #{record_class} with where clause #{where_clause} not found while handling event #{event}
      Severity: Minor
      Found in lib/sequent/core/persistors/active_record_persistor.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 create_sequent_schema_if_not_exists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def create_sequent_schema_if_not_exists(env:, fail_if_exists: true)
                fail ArgumentError, 'env is required' if env.blank?
      
                db_config = Sequent::Support::Database.read_config(env)
      
      
      Severity: Minor
      Found in lib/sequent/migrations/sequent_schema.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

      Method set_table_names_to_new_version has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_table_names_to_new_version(plan)
              plan.replay_tables.each do |migration|
                table = migration.record_class
                next if table.table_name.end_with?("_#{migration.version}")
      
      
      Severity: Minor
      Found in lib/sequent/migrations/executor.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

      Method validation_errors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def validation_errors(prefix = nil)
                result = errors.to_hash
                self.class.types.each do |field|
                  value = instance_variable_get("@#{field[0]}")
                  if value.respond_to? :validation_errors
      Severity: Minor
      Found in lib/sequent/core/helpers/attribute_support.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

      Method event_stream has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def event_stream(aggregate_prefixes, event_types, minimum_xact_id_inclusive, maximum_xact_id_exclusive)
              fail ArgumentError, 'aggregate_prefixes is mandatory' unless aggregate_prefixes.present?
      
              event_stream = Sequent.configuration.event_record_class.where(event_type: event_types)
              event_stream = event_stream.where(<<~SQL, aggregate_prefixes)
      Severity: Minor
      Found in lib/sequent/migrations/view_schema.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

      Method from_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.from_params(value)
          return value if value.is_a?(Date)
      
          value.blank? ? nil : Date.iso8601(value.dup)
        rescue ArgumentError
      Severity: Minor
      Found in lib/sequent/core/ext/ext.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

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

        create_table "stream_records", :force => true do |t|
          t.datetime "created_at", :null => false
          t.string "aggregate_type", :null => false
          t.uuid "aggregate_id", :null => false
          t.integer "snapshot_threshold"
      Severity: Minor
      Found in lib/sequent/generator/template_project/db/sequent_schema.rb and 1 other location - About 25 mins to fix
      integration-specs/rails-app/db/sequent_schema.rb on lines 40..44

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

      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

        create_table "stream_records", :force => true do |t|
          t.datetime "created_at", :null => false
          t.string "aggregate_type", :null => false
          t.uuid "aggregate_id", :null => false
          t.integer "snapshot_threshold"
      Severity: Minor
      Found in integration-specs/rails-app/db/sequent_schema.rb and 1 other location - About 25 mins to fix
      lib/sequent/generator/template_project/db/sequent_schema.rb on lines 37..41

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

      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