Showing 829 of 829 total issues
Method translate_import
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def translate_import(message, &block)
options =
{
headers: message['headers'] || {},
parameters: message['parameters'] || {},
- 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 public
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def public
if (tenant = Tenant.where(id: params[:tenant_id]).first)
tenant.switch do
if (data_type = Setup::FileDataType.where(id: params[:data_type_id]).first)
if data_type.public_read
- 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 associations
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def associations
unless @associations
@associations = {}.with_indifferent_access
properties_schemas.each do |property, property_schema|
if model.model_schema?(property_schema)
- 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_propertyNames
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def check_propertyNames(schema, instance, state, data_type, options)
path = options[:path] || '#'
schema = data_type.merge_schema(schema)
if instance.is_a?(Mongoff::Record)
unless state[:instance_clear]
- 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 json_value
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def json_value(value, options, schema)
case value
when Time, Date, DateTime
value = value.to_time
if schema && schema['format'] == 'time'
- 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 json_value_of
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def json_value_of(value)
return value unless value.is_a?(String)
value = value.strip
if value.blank?
nil
- 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 match?
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def match?(obj, criteria)
criteria.each do |property_name, value|
property_value =
case obj
when Hash
- 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 install
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install(options)
collection = options[:collection]
origin = options[:origin] || (self.origin == :default ? self.class.default_origin : self.origin)
collection.add_dependencies if options[:add_dependencies]
Method do_store_output
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_store_output(output)
rc = []
r = nil
while output.capataz_proxy?
Method save_references
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save_references(record, options, saved, visited = Set.new)
# TODO: Propagate error to parent relation...
return true if visited.include?(record)
visited << record
if record.is_a?(Setup::Collection)
Identical blocks of code found in 2 locations. Consider refactoring. Open
unless target_model.nil? || (target_model.is_a?(Class) && result.is_a?(target_association.klass)) ||
(result.is_a?(Mongoff::Record) && result.is_a?(target_model))
opts = opts.merge(discard_events: true).with_indifferent_access
if transformation.type == :Export && target_model.data_type.is_a?(Setup::FileDataType)
opts[:contentType] ||= transformation.mime_type
- 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 83.
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
unless target_model.nil? || (target_model.is_a?(Class) && result.is_a?(target_association.klass)) ||
(result.is_a?(Mongoff::Record) && result.is_a?(target_model))
opts = opts.merge(discard_events: true).with_indifferent_access
if transformation.type == :Export && target_model.data_type.is_a?(Setup::FileDataType)
opts[:contentType] ||= transformation.mime_type
- 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 83.
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
File ability.rb
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cancan/model_adapters/mongoff_adapter'
require 'setup/storage'
class Ability
include CanCan::Ability
Method index
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
page = get_page
res =
if klass
@render_options.delete(:inspecting)
Method check_additionalProperties
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_additionalProperties(schema, instance, state, data_type, options)
path = options[:path] || '#'
unless (checked_properties = state[:checked_properties])
checked_properties = state[:checked_properties] = Set.new
end
File collection_behavior.rb
has 254 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cenit/cross_tracing_criteria'
module Setup
module CollectionBehavior
extend ActiveSupport::Concern
Method mapping_schema
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def mapping_schema(target_data_type_id = nil)
sch = {
SCHEMA_FLAG.to_s => true,
type: 'object',
properties: {
- 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_requires
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def check_requires(json)
properties = json['properties']
if (required = json['required'])
if required.is_a?(Array)
required.each do |property|
- 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_definitions
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def check_definitions(json, parent, defined_types, embedded_refs, root_schema)
if (defs = json['definitions'])
raise Exception.new('definitions format is invalid') unless defs.is_a?(Hash)
defs.each do |def_name, def_spec|
raise Exception.new("type definition '#{def_name}' is not an object type") unless def_spec.is_a?(Hash) && (def_spec['type'].nil? || def_spec['type'].eql?('object'))
- 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 default_refresh_token
has a Cognitive Complexity of 16 (exceeds 5 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,
- 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"