Showing 121 of 136 total issues
Class SchemaAdapter
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class SchemaAdapter
def initialize(model)
@model = model
end
Method fields_per_model
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def fields_per_model(params_fields, model)
if params_fields
if Rails::VERSION::MAJOR > 4
params_fields_hash = params_fields.to_unsafe_h
else
- 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_relationships
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def extract_relationships
if @params['data']['relationships']
@params['data']['relationships'].each do |name, relationship|
data = relationship['data']
# Rails 3 requires a :sym argument for the reflect_on_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 perform
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform
raw_query = @params['query'].strip
LiveQueryChecker.new(raw_query, 'Live Query Chart').validate()
Method add_columns
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def add_columns
@model.columns.each do |column|
unless is_sti_column_of_child_model?(column)
field_schema = get_schema_for_column(column)
collection.fields << field_schema unless field_schema.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
Class FiltersParser
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class FiltersParser
AGGREGATOR_OPERATOR = %w(and or)
def initialize(filters, resource, timezone, params = nil)
@filters = filters
Method initialize
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize filename, collections, meta
@filename = filename
@meta = meta
# NOTICE: Remove unecessary keys
Method field
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def field(name, opts, &block)
# TODO: Handle empty name
if opts.key?(:isRequired)
FOREST_LOGGER.warn "DEPRECATION WARNING: isRequired on field \"#{name}\" is deprecated. Please use is_required."
Method send_apimap
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_apimap(with_feedback=false)
if ForestLiana.env_secret && ForestLiana.env_secret.length != 64
FOREST_LOGGER.error "Your env_secret does not seem to be correct. " \
"Can you check on Forest that you copied it properly in the " \
"forest_liana initializer?"
Method initialize
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(attributes = {})
if attributes.key?(:global)
FOREST_LOGGER.error "REMOVED OPTION: The support for Smart Action \"global\" option is now " \
"removed. Please set \"type: 'global'\" instead of \"global: true\" for the " \
"\"#{attributes[:name]}\" Smart Action."
Method perform
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform
add_columns
add_associations
collection.fields.sort_by!.with_index { |k, idx| [k[:field].to_s, idx] }
Method render_csv
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def render_csv getter, model
set_headers_file
set_headers_streaming
response.status = 200
- 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 call(env)
params = env['action_dispatch.request.path_parameters']
collection_name = params[:collection]
resource = ForestLiana::SchemaUtils.find_model_from_collection_name(collection_name, 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 setup_intercom_integration
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_intercom_integration(collection_name)
model_name = ForestLiana.name_for(collection_name.constantize)
# TODO: Remove once lianas prior to 2.0.0 are not supported anymore.
model_name_old = ForestLiana.name_old_for(collection_name.constantize)
Method set_has_many_relationships
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def set_has_many_relationships
if @params['data']['relationships']
@params['data']['relationships'].each do |name, relationship|
data = relationship['data']
association = @resource.reflect_on_association(name.to_sym)
- 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 a Cognitive Complexity of 14 (exceeds 5 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
- 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 get_date_filter
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_date_filter(operator, value)
return nil unless is_date_operator? operator
filter = case operator
when OPERATOR_FUTURE
Method install
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install
if ForestLiana.env_secret.present?
puts "\nForest liana already installed on this app.\nHere is your current environment " +
"secret: #{ForestLiana.env_secret}\nYou can update the config/secrets.yml file with the " +
"new environment secret: #{env_secret}"
Method call
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
params = env['action_dispatch.request.path_parameters']
collection_name = params[:collection]
resource = ForestLiana::SchemaUtils.find_model_from_collection_name(collection_name, true)
Method pretty_print
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pretty_print json, indentation = ""
result = ""
if json.kind_of? Array
result << "["