zilverline/sequent

View on GitHub

Showing 46 of 47 total issues

Method register_tasks! has 188 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def register_tasks!
        namespace :sequent do
          desc <<~EOS
            Set the SEQUENT_ENV to RAILS_ENV or RACK_ENV if not already set
          EOS
Severity: Major
Found in lib/sequent/rake/migration_tasks.rb - About 7 hrs to fix

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

          def register_tasks!
            namespace :sequent do
              desc <<~EOS
                Set the SEQUENT_ENV to RAILS_ENV or RACK_ENV if not already set
              EOS
    Severity: Minor
    Found in lib/sequent/rake/migration_tasks.rb - About 6 hrs 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

    File view_schema.rb has 307 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'parallel'
    require 'postgresql_cursor'
    
    require_relative 'errors'
    require_relative '../support/database'
    Severity: Minor
    Found in lib/sequent/migrations/view_schema.rb - About 3 hrs to fix

      Class ViewSchema has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class ViewSchema
            # Corresponds with the index on aggregate_id column in the event_records table
            #
            # Since we replay in batches of the first 3 chars of the uuid we created an index on
            # these 3 characters. Hence the name ;-)
      Severity: Minor
      Found in lib/sequent/migrations/view_schema.rb - About 3 hrs to fix

        File replay_optimized_postgres_persistor.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'set'
        require 'active_record'
        require 'csv'
        require_relative './persistor'
        
        
        Severity: Minor
        Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.rb - About 2 hrs to fix

          Class ReplayOptimizedPostgresPersistor has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

                class ReplayOptimizedPostgresPersistor
                  include Persistor
                  CHUNK_SIZE = 1024
          
                  attr_reader :record_store
          Severity: Minor
          Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.rb - About 2 hrs to fix

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

                    def from_params(params, strict_nil_check = true)
                      params = HashWithIndifferentAccess.new(params)
                      self.class.types.each do |attribute, type|
                        value = params[attribute]
            
            
            Severity: Minor
            Found in lib/sequent/core/helpers/param_support.rb - About 2 hrs 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 commit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def commit
                      @record_store.each do |clazz, records|
                        @column_cache ||= {}
                        @column_cache[clazz.name] ||= clazz.columns.reduce({}) do |hash, column|
                          hash.merge({column.name => column})
            Severity: Minor
            Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.rb - About 1 hr to fix

              Method map_to_migrations has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                    def map_to_migrations(migrations)
                      migrations.reduce({}) do |memo, (version, ms)|
                        unless ms.is_a?(Array)
                          fail InvalidMigrationDefinition,
                               "Declared migrations for version #{version} must be an Array. For example: {'3' => [FooProjector]}"
              Severity: Minor
              Found in lib/sequent/migrations/planner.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

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

                    def append_command_handler
                      ast = Parser::CurrentRuby.parse(File.read("#{path_to_dir}/#{name_underscored}_command_handler.rb"))
                      target_cursor_position = find_target_cursor_position(ast)
              
                      File.open("#{path_to_dir}/#{name_underscored}_command_handler.rb", 'r+') do |f|
              Severity: Major
              Found in lib/sequent/generator/command.rb and 1 other location - About 1 hr to fix
              lib/sequent/generator/event.rb on lines 35..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 62.

              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 append_event_to_domain
                      ast = Parser::CurrentRuby.parse(File.read("#{path_to_dir}/#{name_underscored}.rb"))
                      target_cursor_position = find_target_cursor_position(ast)
              
                      File.open("#{path_to_dir}/#{name_underscored}.rb", 'r+') do |f|
              Severity: Major
              Found in lib/sequent/generator/event.rb and 1 other location - About 1 hr to fix
              lib/sequent/generator/command.rb on lines 33..42

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

              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 replay! has 36 lines of code (exceeds 25 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 1 hr to fix

                Method process_event has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                        def process_event(event)
                          [*Sequent::Core::Workflow.descendants, *Sequent::Core::Projector.descendants].each do |handler_class|
                            next unless handler_class.handles_message?(event)
                
                            if handler_class < Sequent::Workflow
                Severity: Minor
                Found in lib/sequent/util/dry_run.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 initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize
                      self.command_handlers = []
                      self.command_filters = []
                      self.event_handlers = []
                      self.command_middleware = Sequent::Core::Middleware::Chain.new
                Severity: Minor
                Found in lib/sequent/configuration.rb - About 1 hr to fix

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

                          def validate(record)
                            associations = options[:associations]
                            associations = [associations] unless associations.instance_of?(Array)
                            associations.each do |association|
                              value = record.instance_variable_get("@#{association}")
                  Severity: Minor
                  Found in lib/sequent/core/helpers/association_validator.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 == has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def ==(other)
                            return false if other.nil?
                            return false if self.class != other.class
                  
                            self.class.types.each do |name, _|
                  Severity: Minor
                  Found in lib/sequent/core/helpers/equal_support.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 migrate_online has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def migrate_online
                          ensure_valid_plan!
                          migrate_metadata_tables
                  
                          return if Sequent.new_version == current_version
                  Severity: Minor
                  Found in lib/sequent/migrations/view_schema.rb - About 1 hr to fix

                    Method attrs has 28 lines of code (exceeds 25 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 1 hr to fix

                      Method as_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def as_params
                                hash = HashWithIndifferentAccess.new
                                self.class.types.each do |field|
                                  value = instance_variable_get("@#{field[0]}")
                                  next if field[0] == 'errors'
                      Severity: Minor
                      Found in lib/sequent/core/helpers/param_support.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 commit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def commit
                                @record_store.each do |clazz, records|
                                  @column_cache ||= {}
                                  @column_cache[clazz.name] ||= clazz.columns.reduce({}) do |hash, column|
                                    hash.merge({column.name => column})
                      Severity: Minor
                      Found in lib/sequent/core/persistors/replay_optimized_postgres_persistor.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

                      Severity
                      Category
                      Status
                      Source
                      Language