Showing 255 of 255 total issues
Method perform_load
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform_load( options = {} )
allow_empty_rows = DataShift::Loaders::Configuration.call.allow_empty_rows
logger.info "Starting bulk load from Excel : #{file_name}"
Assignment Branch Condition size for prepare_from_yaml is too high. [63/60] Open
def prepare_from_yaml(yaml, locale_key = 'data_flow_schema')
@yaml_data = yaml
raise "Bad YAML syntax - No key #{locale_key} found in #{yaml}" unless yaml[locale_key]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Perceived complexity for prepare_data is too high. [18/15] Open
def prepare_data(method_binding, data)
raise NilDataSuppliedError, 'No method_binding supplied for prepare_data' unless method_binding
@original_data = data
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Method prepare_from_yaml
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_from_yaml(yaml, locale_key = 'data_flow_schema')
@yaml_data = yaml
raise "Bad YAML syntax - No key #{locale_key} found in #{yaml}" unless yaml[locale_key]
Method perform_load
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform_load( _options = {} )
require 'csv'
raise "Cannot load - failed to create a #{klass}" unless load_object
Method require_libraries
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.require_libraries
loader_libs = %w[lib]
# Base search paths - these will be searched recursively
- 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 file_set_field_by_map
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def file_set_field_by_map( file_name, fields, value_map, regex = nil )
lines = []
objects = []
- 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 call
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.call(record, value, operator)
logger.debug("Attempting Brute force assignment of value #{value} => [#{operator}]")
return if(attempt(record, value, operator))
- 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
Perceived complexity for perform_load is too high. [17/15] Open
def perform_load( options = {} )
allow_empty_rows = DataShift::Loaders::Configuration.call.allow_empty_rows
logger.info "Starting bulk load from Excel : #{file_name}"
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Perceived complexity for assign is too high. [17/15] Open
def assign(method_binding, record)
model_method = method_binding.model_method
operator = model_method.operator
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Method map_inbound_headers
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def map_inbound_headers(klass, columns)
# If klass not in Dictionary yet, add to dictionary all possible operators on klass
# which can be used to map headers and populate an object of type klass
model_methods_collection = ModelMethods::Manager.catalog_class(klass)
Method call
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.call(load_object, value, method_binding)
# there are times when we need to save early, for example before assigning to
# has_and_belongs_to associations which require the load_object has an id for the join table
Assignment Branch Condition size for call is too high. [61.85/60] Open
def self.call(load_object, value, method_binding)
# there are times when we need to save early, for example before assigning to
# has_and_belongs_to associations which require the load_object has an id for the join table
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method results_to_sheet
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def results_to_sheet( results, sheet, mappings = nil, header = true)
numrows = results.length
sheet_name = sheet
if numrows == 0
Method assign
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def assign(method_binding, record)
model_method = method_binding.model_method
operator = model_method.operator
Block has too many lines. [41/25] Open
[*columns].each_with_index do |col_data, col_index|
raw_col_data = col_data.to_s.strip
if raw_col_data.nil? || raw_col_data.empty?
logger.warn("Column list contains empty or null header at index #{col_index}")
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Method populate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.populate(klass, options = {} )
raise "Cannot find operators supplied klass nil #{klass}" if klass.nil?
register(klass)
- 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 determine_operator_class
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def determine_operator_class
if operator_for(:has_many) || operator_for(:belongs_to) || operator_for(:has_one)
result = klass.reflect_on_association(operator)
- 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_import_config
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_import_config(klass_or_name, options = {})
klass = MapperUtils.ensure_class(klass_or_name)
@key = 'data_flow_schema'
Method export_with_associations
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def export_with_associations(file_name, klass, export_records, options = {})
records = [*export_records]
state = DataShift::Configuration.call.with