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
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
- 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
File view_schema.rb
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'parallel'
require 'postgresql_cursor'
require_relative 'errors'
require_relative '../support/database'
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 ;-)
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'
Class ReplayOptimizedPostgresPersistor
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ReplayOptimizedPostgresPersistor
include Persistor
CHUNK_SIZE = 1024
attr_reader :record_store
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]
- 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 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})
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]}"
- 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
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|
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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|
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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,
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
- 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 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
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}")
- 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 ==
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, _|
- 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 migrate_online
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def migrate_online
migrate_metadata_tables
ensure_valid_plan!
return if Sequent.new_version == current_version
Method attrs
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attrs(args)
validate_attrs!(args)
@types.merge!(args)
associations = []
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})
- 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 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'
- 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"