Showing 829 of 829 total issues
Method select_items
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def select_items
asc = true
if (order = @criteria.delete(:order))
order.strip!
asc = !order.match(/^-.*/)
- 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 start
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def start
Thread.new do
Cenit::Redis.new.subscribe(:hook) do |on|
on.subscribe do |channel, subscriptions|
puts "Redis Hook adapter subscribed to ##{channel} (#{subscriptions} subscriptions)"
- 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 diff
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def diff(other_scope)
other_scope = self.class.new(other_scope.to_s) unless other_scope.is_a?(self.class)
diff = self.class.new
if auth? && !other_scope.auth?
diff.instance_variable_set(:@auth, true)
- 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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
@deferred_abilities = []
deferred_abilities <<
if (@user = user)
- 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 authorize_action
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def authorize_action
if klass
action_symbol =
case @_action_name
when 'push'
- 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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize(model, array, referenced, parent)
@null = !array
array ||= []
@parent = parent
@model = model
- 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 send
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def send(*args)
name = args[0].to_s
property_name = (assigning = name.end_with?('=')) ? name.chop : name
if (method = orm_model.data_type.records_methods.detect { |alg| alg.name == name })
args = args.dup
- 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 check_contains
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def check_contains(contains_schema, items, state, data_type, options, schema)
return unless items.is_a?(Mongoff::RecordArray) || items.is_a?(Array)
contains_schema = data_type.merge_schema(contains_schema)
data_type = items.orm_model.data_type if items.is_a?(Mongoff::RecordArray)
max_min = schema['maxContains'] || schema['minContains']
- 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 bundled_javascript_code
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def bundled_javascript_code(algorithm)
arguments_param = false
i = -1
js_vars = ''
params_initializer =
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (t_data_type = transformation.data_type).nil? || t_data_type == source_dt
unless transformation.type == :Export
sub_map_target_dt = target_data_type.records_model.property_model(name).data_type
t_target_dt = transformation.target_data_type
unless t_target_dt == sub_map_target_dt
- 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 60.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (t_data_type = transformation.data_type).nil? || t_data_type == source_dt
unless transformation.type == :Export
sub_map_target_dt = target_data_type.records_model.property_model(name).data_type
t_target_dt = transformation.target_data_type
unless t_target_dt == sub_map_target_dt
- 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 60.
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 source_options
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def source_options(options, source_key_options)
data_type_key = source_key_options[:data_type_key] || :source_data_type
if (data_type = send(data_type_key) || options[data_type_key] || options[:data_type])
model = data_type.records_model
offset = options[:offset] || 0
Method check_embedded_items
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_embedded_items(item, record)
(item_model = record.class).model_properties_schemas.each do |property, schema|
next if schema['referenced']
next unless (property_value = item[property]) && (property_model = item_model.property_model(property))
next unless (property_data_type = property_model.data_type).get_referenced_by.present?
Method run
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(message)
message = message.with_indifferent_access
json_schemas = Setup::DataTypeGeneration.data_type_schemas(message[:source], { data_type_names: data_type_names = {} })
json_schemas.each do |ns, data_type_schemas|
existing_data_types = Setup::DataType.any_in(namespace: ns, name: data_type_schemas.keys)
Method default_refresh_token
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def default_refresh_token(authorization)
if (refresh_token = authorization.refresh_token) && is_time_to_refresh?(authorization)
fail 'Missing client configuration' unless (client = authorization.client)
http_response = HTTMultiParty.post(
authorization.token_endpoint,
Method get_data_type_by_slug
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_data_type_by_slug(slug)
if slug
@data_types[slug] ||=
begin
build_in = nil
Method check_dependentSchemas
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_dependentSchemas(properties, instance, _, data_type)
return unless instance
if instance.is_a?(Mongoff::Record)
has_errors = false
stored_properties = instance.orm_model.stored_properties_on(instance).map(&:to_s)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def new_from_xml(string_or_readable, options = {})
if data_type_methods.any? { |alg| alg.name == 'new_from_xml' }
return method_missing(:new_from_xml, string_or_readable, options)
end
if options[:data_type_parser]
- 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 58.
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 new_from_edi(string_or_readable, options = {})
if data_type_methods.any? { |alg| alg.name == 'new_from_edi' }
return method_missing(:new_from_edi, string_or_readable, options)
end
if options[:data_type_parser]
- 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 58.
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
Consider simplifying this complex logical expression. Open
if source_key_options[:bulk]
{
source_key_options[:sources_key] || :sources =>
if (object_ids = options[:object_ids])
model.any_in(id: (limit ? object_ids[offset, limit] : object_ids.from(offset))).to_enum