Showing 59 of 59 total issues
Method add_scope
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_scope(key, args)
sanitized_args = if Ransack.options[:sanitize_scope_args] && !@context.ransackable_scope_skip_sanitize_args?(key, @context.object)
sanitized_scope_args(args)
else
args
- 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 join_constraints_with_tables
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
joins = []
chain = []
reflection.chain.each.with_index do |reflection, i|
Method attribute
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attribute(key, options = {})
unless context = options.delete(:context)
raise ArgumentError, "A context is required to translate attributes"
end
Method build_joins
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_joins(relation)
buckets = relation.joins_values + relation.left_outer_joins_values
buckets = buckets.group_by do |join|
case join
Method predicate_select
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def predicate_select(options = {}, html_options = {})
options[:compounds] = true if options[:compounds].nil?
default = options.delete(:default) || Constants::CONT
keys =
- 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 attribute_method?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def attribute_method?(str, klass = @klass)
exists = false
if ransackable_attribute?(str, klass)
exists = true
elsif (segments = str.split(Constants::UNDERSCORE)).size > 1
- 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 collapse_multiparameter_attributes!
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def collapse_multiparameter_attributes!(attrs)
attrs.keys.each do |k|
if k.include?(Constants::LEFT_PARENTHESIS)
real_attribute, position = k.split(/\(|\)/)
cast =
Method extract_values_for_condition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def extract_values_for_condition(key, context = nil)
str = key.dup
name = Predicate.detect_and_strip_from_string!(str)
predicate = Predicate.named(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 join_constraints_with_tables
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
joins = []
chain = []
reflection.chain.each.with_index do |reflection, i|
- 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 arel_predicate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def arel_predicate
predicate = attributes.map { |attribute|
association = attribute.parent
if negative? && attribute.associated_collection?
query = context.build_correlated_subquery(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 get_parent_and_attribute_name
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_parent_and_attribute_name(str, parent = @base)
attr_name = nil
if ransackable_attribute?(str, klassify(parent))
attr_name = str
- 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 search_form_for
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def search_form_for(record, options = {}, &proc)
if record.is_a? Ransack::Search
search = record
options[:url] ||= polymorphic_path(
search.klass, format: options.delete(:format)
- 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 cast_to_date
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def cast_to_date(val)
if val.respond_to?(:to_date)
val.to_date rescue nil
else
y, m, d = *[val].flatten
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def extract(context, key, values)
attributes, predicate, combinator =
extract_values_for_condition(key, context)
if attributes.size > 0 && predicate
- 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 join_constraints_with_tables
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
Method join_constraints_with_tables
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
Method type_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def type_for(attr)
return nil unless attr && attr.valid?
relation = attr.arel_attribute.relation
name = attr.arel_attribute.name.to_s
table = relation.respond_to?(:table_name) ? relation.table_name : relation.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 attribute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def attribute(key, options = {})
unless context = options.delete(:context)
raise ArgumentError, "A context is required to translate attributes"
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 conditions=
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def conditions=(conditions)
case conditions
when Array
conditions.each do |attrs|
condition = Condition.new(@context).build(attrs)
- 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_from_string
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def detect_from_string(str, chomp: false)
return unless str
Ransack.predicates.sorted_names_with_underscores.each do |predicate, underscored|
if str.end_with? underscored
- 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"