Showing 96 of 136 total issues
Method init_properties_with_default
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def init_properties_with_default
@name_old ||= @name
@is_virtual ||= false
@icon ||= nil
@is_read_only ||= false
Method validate_field
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.validate_field(field, action_name)
raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, nil, "The field attribute must be defined") if !field || field[:field].nil?
raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, nil, "The field attribute must be a string.") if !field[:field].is_a?(String)
raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, field[:field], "The description attribute must be a string.") if field[:description] && !field[:description].is_a?(String)
raise ForestLiana::Errors::SmartActionInvalidFieldError.new(action_name, field[:field], "The enums attribute must be an array.") if field[:enums] && !field[:enums].is_a?(Array)
- 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 perform
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def perform(resource)
@resource = @records = resource
@tables_associated_to_relations_name =
ForestLiana::QueryHelper.get_tables_associated_to_relations_name(@resource)
@records = search_param
- 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 generate_action_hooks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def generate_action_hooks()
@collections_sent.each do |collection|
collection['actions'].each do |action|
c = get_collection(collection['name'])
unless c.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 extract_carrierwave
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def extract_carrierwave
return if @params['data']['attributes'].blank?
return unless @resource.respond_to?(:uploaders)
@params['data']['attributes'].each do |key, value|
- 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 perform
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def perform
if @params[:groupByFieldName]
timezone_offset = @params[:timezone].to_i
resource = optimize_record_loading(@resource, get_resource)
- 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 perform
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def perform
@record = @resource.find(@params[:id])
associated_records = @resource.find(@params[:id]).send(@association.name)
remove_association = !@with_deletion || @association.macro == :has_and_belongs_to_many
- 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 compute_includes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def compute_includes
@includes = @association.klass
.reflect_on_all_associations
.select do |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 handle_result
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_result(result, action)
if result.nil? || !result.is_a?(Array)
return render status: 500, json: { error: 'Error in smart action load hook: hook must return an array of fields' }
end
Method field_names_requested
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def field_names_requested
return nil unless @params[:fields] && @params[:fields][@collection_name]
associations_for_query = []
- 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 parse_aggregation_on_previous_interval
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def parse_aggregation_on_previous_interval(node, previous_condition)
raise_empty_condition_in_filter_error unless node
return parse_previous_interval_condition(node) unless node['aggregator']
- 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 reject_unauthorized_ip
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def reject_unauthorized_ip
begin
ip = request.remote_ip
if !ForestLiana::IpWhitelist.is_ip_whitelist_retrieved || !ForestLiana::IpWhitelist.is_ip_valid(ip)
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(reset_api_map = false)
if reset_api_map
ForestLiana.apimap = []
ForestLiana.models = []
end
- 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 extract_attributes_serialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extract_attributes_serialize
attributes_serialized.each do |attribute, serializer|
value = @params[:data][:attributes][attribute]
begin
if @attributes.has_key?(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
Avoid deeply nested control flow statements. Open
if @collection.search_fields.nil? || (association_search &&
association_search.include?(column.name))
conditions << association_search_condition(resource.table_name,
column.name)
end
Avoid deeply nested control flow statements. Open
if !(column.respond_to?(:array) && column.array) && text_type?(column.type)
if association_search.include?(column.name)
conditions << association_search_condition(resource.table_name,
column.name)
end
Method sort_query
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sort_query
if @params[:sort]
@params[:sort].split(',').each do |field|
order_detected = detect_sort_order(field)
order = order_detected.upcase
- 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 fetch_model
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fetch_model(model)
return if model.abstract_class?
return if ForestLiana.models.include?(model)
return unless analyze_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 find_model_from_collection_name
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.find_model_from_collection_name(collection_name, logs = false)
model_found = nil
ForestLiana.models.each do |model|
if model.abstract_class?
model_found = self.find_model_from_abstract_class(model, collection_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 detect_match_and_decorate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.detect_match_and_decorate record, index, field_name, value, search_value, match_fields