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(
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
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|
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)
)
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
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
- Read upRead up
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
- Read upRead up
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])
- Read upRead up
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)
Method add_item
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_item(product_id, title, unit_price, vat_rate, quantity)
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
- Read upRead up
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"