RailsEventStore/cqrs-es-sample-with-res

View on GitHub

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

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

        class Configuration
          def call(event_store)
            event_store.subscribe(
              -> (event) {Product.create(product_id: event.data[:product_id])},
              to: [ProductCatalog::ProductRegistered])
      pricing_catalog_rails_app/app/admin/read_models/admin_catalog/admin_catalog.rb on lines 19..32

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

      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

        class Configuration
          def call(event_store)
            event_store.subscribe(
              -> (event) {Product.create(product_id: event.data[:product_id])},
              to: [ProductCatalog::ProductRegistered])
      pricing_catalog_rails_app/app/public/read_models/public_catalog/public_catalog.rb on lines 19..32

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

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

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

                    def build_state(event)
                      stream_name = "PaymentProcess$#{event.data.fetch(:order_id)}"
                      past_events = event_store.read.stream(stream_name).to_a
                      last_stored = past_events.size - 1
                      event_store.link(event.event_id, stream_name: stream_name, expected_version: last_stored)
                ecommerce/processes/lib/processes/shipment_process.rb on lines 35..45

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

                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 build_state(event)
                      stream_name = "ShipmentProcess$#{event.data.fetch(:order_id)}"
                      past_events = event_store.read.stream(stream_name).to_a
                      last_stored = past_events.size - 1
                      event_store.link(event.event_id, stream_name: stream_name, expected_version: last_stored)
                Severity: Major
                Found in ecommerce/processes/lib/processes/shipment_process.rb and 1 other location - About 1 hr to fix
                ecommerce/processes/lib/processes/release_payment_process.rb on lines 21..31

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

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

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

                        create_table(:event_store_events, id: false, force: false) do |t|
                          t.string :id, limit: 36, primary_key: true, null: false
                          t.string      :event_type,  null: false
                          t.text        :metadata
                          t.text        :data,        null: false
                  rails_application/db/migrate/20181207145051_binary_data_and_metadata.rb on lines 8..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 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

                        create_table(:event_store_events, id: false, force: false) do |t|
                          t.string :id, limit: 36, primary_key: true, null: false
                          t.string      :event_type,  null: false
                          t.binary      :metadata
                          t.binary      :data,        null: false
                  rails_application/db/migrate/20181102132612_create_event_store_events.rb on lines 29..35

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

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

                    def change
                      drop_table :happy_hours, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
                        t.string :name
                        t.string :code
                        t.integer :discount
                  Severity: Minor
                  Found in rails_application/db/migrate/20220703122711_drop_happy_hours.rb and 1 other location - About 40 mins to fix
                  rails_application/db/migrate/20220528213429_create_happy_hours.rb on lines 2..11

                  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

                    def change
                      create_table :happy_hours, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
                        t.string :name
                        t.string :code
                        t.integer :discount
                  rails_application/db/migrate/20220703122711_drop_happy_hours.rb on lines 2..11

                  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 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
                    Severity
                    Category
                    Status
                    Source
                    Language