RailsEventStore/cqrs-es-sample-with-res

View on GitHub

Showing 14 of 41 total issues

Method call has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def call(event_store, command_bus)
      Pricing.event_store = event_store
      Pricing.command_bus = command_bus

      command_bus.register(
Severity: Major
Found in ecommerce/pricing/lib/pricing.rb - About 2 hrs to fix

    Method change has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def change
        case ActiveRecord::Base.connection.adapter_name
        when "SQLite"
          rename_table :event_store_events, :old_event_store_events
          create_table(:event_store_events, force: false) do |t|

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

          def products_table(products)
            if products.count > 0
              table class: "w-full" do
                thead do
                  tr class: "border-t" do
      Severity: Minor
      Found in rails_application/app/read_models/public_offer/configuration.rb - About 1 hr to fix

        Method change has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def change
            postgres = ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
            sqlite   = ActiveRecord::Base.connection.adapter_name == "SQLite"
            rails_42 = Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("5.0.0")
            enable_extension "pgcrypto" if postgres

          Method change has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def change
              case ActiveRecord::Base.connection.adapter_name
              when "SQLite"
                rename_table :event_store_events, :old_event_store_events
                create_table(:event_store_events, id: false, force: false) do |t|
          Severity: Minor
          Found in rails_application/db/migrate/20210103114304_created_at_precision.rb - About 1 hr to fix

            Method call has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def call(event_store, command_bus)
                  command_bus.register(
                    SetProductNameDisplayedOnInvoice,
                    SetProductNameDisplayedOnInvoiceHandler.new(event_store)
                  )
            Severity: Minor
            Found in ecommerce/invoicing/lib/invoicing.rb - About 1 hr to fix

              Method call has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def call(event_store)
                    @event_store = event_store
              
                    Rails.configuration.broadcaster = Orders::Broadcaster.new
              
              
              Severity: Minor
              Found in rails_application/app/read_models/orders/configuration.rb - About 1 hr to fix

                Method change has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def change
                    rails_42 = Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("5.0.0")
                
                    case ActiveRecord::Base.connection.adapter_name
                    when "SQLite"

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

                      def products_table(products)
                        if products.count > 0
                          table class: "w-full" do
                            thead do
                              tr class: "border-t" do
                  Severity: Minor
                  Found in rails_application/app/read_models/public_offer/configuration.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 change has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def change
                      postgres = ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
                      sqlite   = ActiveRecord::Base.connection.adapter_name == "SQLite"
                      rails_42 = Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("5.0.0")
                      enable_extension "pgcrypto" if postgres
                  Severity: Minor
                  Found in rails_application/db/migrate/20181102132612_create_event_store_events.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def create
                      ActiveRecord::Base.transaction do
                        create_product(params[:product_id], params[:name])
                        if params[:price].present?
                          set_product_price(params[:product_id], params[:price])
                  Severity: Minor
                  Found in rails_application/app/controllers/products_controller.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def initialize(product_id, title, unit_price, vat_rate, quantity)
                  Severity: Minor
                  Found in ecommerce/invoicing/lib/invoicing/invoice.rb - About 35 mins to fix

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

                        def add_item(product_id, title, unit_price, vat_rate, quantity)
                    Severity: Minor
                    Found in ecommerce/invoicing/lib/invoicing/invoice.rb - About 35 mins to fix

                      Method concurrent_safely has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def concurrent_safely(event)
                          stream_name = "#{active_record_name}$#{record_id(event)}$#{event.event_type}"
                          read_scope = event_store.read.as_at.stream(stream_name)
                          begin
                            last_event = read_scope.last
                      Severity: Minor
                      Found in rails_application/app/read_models/single_table_read_model.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

                      Severity
                      Category
                      Status
                      Source
                      Language