Showing 9 of 12 total issues
Class AdapterDecorator
has 47 methods (exceeds 20 allowed). Consider refactoring. Confirmed
class AdapterDecorator < SimpleDelegator
SUPPORTED_PARTITION_TYPES = %i[range list hash].freeze
def initialize(adapter)
super(adapter)
File adapter_decorator.rb
has 359 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "digest"
require 'parallel'
module PgParty
class AdapterDecorator < SimpleDelegator
Method create_table_like
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def create_table_like(table_name, new_table_name, **options)
primary_key = options.fetch(:primary_key) { calculate_primary_key(table_name) }
partition_key = options.fetch(:partition_key, nil)
partition_type = options.fetch(:partition_type, nil)
create_with_pks = options.fetch(
- 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 recursive_add_index
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def recursive_add_index(table_name:, index_name:, index_type:, index_columns:, index_options:, using:, algorithm:,
in_threads: nil, _parent_index_name: nil, _created_index_names: [])
partitions = partitions_for_table_name(table_name, include_subpartitions: false)
updated_name = _created_index_names.empty? ? index_name : generate_index_name(index_name, table_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 create_partition
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_partition(table_name, type, partition_key, **options, &blk)
modified_options = options.except(:id, :primary_key, :template, :create_with_primary_key)
template = options.fetch(:template, PgParty.config.create_template_tables)
id = options.fetch(:id, :bigserial)
primary_key = options.fetch(:primary_key) { calculate_primary_key(table_name) }
Method recursive_add_index
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def recursive_add_index(table_name:, index_name:, index_type:, index_columns:, index_options:, using:, algorithm:,
in_threads: nil, _parent_index_name: nil, _created_index_names: [])
partitions = partitions_for_table_name(table_name, include_subpartitions: false)
updated_name = _created_index_names.empty? ? index_name : generate_index_name(index_name, table_name)
Method extract_index_options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def extract_index_options(add_index_options_result)
# Rails 6.1 changes the result of #add_index_options
index_definition = add_index_options_result.first
return add_index_options_result unless index_definition.is_a?(ActiveRecord::ConnectionAdapters::IndexDefinition)
- 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_table_like
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_table_like(table_name, new_table_name, **options)
primary_key = options.fetch(:primary_key) { calculate_primary_key(table_name) }
partition_key = options.fetch(:partition_key, nil)
partition_type = options.fetch(:partition_type, nil)
create_with_pks = options.fetch(
Method create_partition
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_partition(table_name, type, partition_key, **options, &blk)