Showing 13 of 408 total issues
Method validate_array_items
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def validate_array_items(value)
# must be a collection of items
if !value.respond_to?(:each) || !value.respond_to?(:all?) || !value.respond_to?(:any?) || !value.respond_to?(:count)
fail Clearly::Query::QueryArgumentError, "must be a collection of items, got '#{value.class}'"
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
Class Custom
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Custom
include Clearly::Query::Compose::Comparison
include Clearly::Query::Compose::Core
include Clearly::Query::Compose::Range
include Clearly::Query::Compose::Subset
Method traverse_branches
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def traverse_branches(current_node, current_path)
child_nodes = current_node.include?(@child_key) ? current_node[@child_key] : []
current_node_no_children = current_node.dup.except(@child_key)
- 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 subquery
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def subquery(definition, other_definition, conditions)
validate_definition_instance(definition)
validate_definition_instance(other_definition)
[conditions].flatten.each { |c| validate_node_or_attribute(c) }
Method build_associations_flat
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_associations_flat(associations)
joins = []
if associations.is_a?(Array)
more_associations = associations.map { |i| build_associations_flat(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 condition_node_subset
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def condition_node_subset(operator, node, value)
case operator
when :range, :in_range
compose_range_node(node, value)
when :not_range, :not_in_range
Method subquery
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def subquery(definition, other_definition, conditions)
validate_definition_instance(definition)
validate_definition_instance(other_definition)
[conditions].flatten.each { |c| validate_node_or_attribute(c) }
- 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_range
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def parse_range(hash)
unless hash.is_a?(Hash)
fail Clearly::Query::QueryArgumentError.new(
"range filter must be {'from': 'value', 'to': 'value'} " +
"or {'interval': '(|[.*,.*]|)'} got '#{hash}'", {hash: 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 condition_combine_new
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def condition_combine_new(combiner, conditions, new_condition)
case combiner
when :and
conditions.nil? ? new_condition : compose_and(conditions, new_condition)
when :or
- 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_conditions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_conditions(definition, query_key, query_value)
if query_value.blank? || query_value.size < 1
msg = "filter hash must have at least 1 entry, got '#{query_value.size}'"
fail Clearly::Query::QueryArgumentError.new(msg, {hash: query_value})
end
Method parse_conditions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_conditions(definition, query_key, query_value)
if query_value.blank? || query_value.size < 1
msg = "filter hash must have at least 1 entry, got '#{query_value.size}'"
fail Clearly::Query::QueryArgumentError.new(msg, {hash: query_value})
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 condition_components
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def condition_components(operator, table, column_name, valid_fields, value)
Method validate_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_name(name, allowed)
validate_not_blank(name)
fail Clearly::Query::QueryArgumentError, "name must be a symbol, got '#{name}'" unless name.is_a?(Symbol)
fail Clearly::Query::QueryArgumentError, "allowed must be an Array, got '#{allowed}'" unless allowed.is_a?(Array)
fail Clearly::Query::QueryArgumentError, "name must be in '#{allowed}', got '#{name}'" unless allowed.include?(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"