Showing 23 of 23 total issues
Class Validator
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Validator < AgnosticBackend::Queryable::Visitor
include AgnosticBackend::Utilities
def initialize
Class Visitor
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Visitor
def visit(subject)
method_name = class_to_method_name(subject.class)
send(method_name, subject)
end
Class SimpleVisitor
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class SimpleVisitor < AgnosticBackend::Queryable::Visitor
private
def visit_criteria_equal(subject)
Class Visitor
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Visitor < AgnosticBackend::Queryable::Visitor
private
def visit_criteria_equal(subject)
Class Visitor
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Visitor < AgnosticBackend::Queryable::Visitor
private
def visit_criteria_equal(subject)
Method convert_to
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def convert_to(type, value)
case type
when :integer
if value.is_a?(Fixnum)
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 visit_value
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def visit_value(subject)
case subject.type
when :integer
unless subject.value.is_a?(Fixnum)
subject.context.query.errors[subject.class.name] << value_error(subject)
- 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 convert_to
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_to(type, value)
case type
when :integer
if value.is_a?(Fixnum)
value
Method define_fields_in_domain
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def define_fields_in_domain(flat_schema, verbose: true)
remote_fields = cloudsearch_client.describe_index_fields(domain_name: domain_name).
index_fields.map{|field| RemoteIndexField.new(field)}
puts "Found #{remote_fields.size} remote fields in #{domain_name}" if verbose
local_fields = index_fields(flat_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 visit_value
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def visit_value(subject)
case subject.type
when :integer
unless subject.value.is_a?(Fixnum)
subject.context.query.errors[subject.class.name] << value_error(subject)
Similar blocks of code found in 2 locations. Consider refactoring. Open
TYPE_MAPPINGS = {
AgnosticBackend::Indexable::FieldType::STRING => "string",
AgnosticBackend::Indexable::FieldType::STRING_ARRAY => "string",
AgnosticBackend::Indexable::FieldType::DATE => "date",
AgnosticBackend::Indexable::FieldType::DATE_ARRAY => "date",
- 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 48.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
TYPE_MAPPINGS = {
AgnosticBackend::Indexable::FieldType::STRING => "literal",
AgnosticBackend::Indexable::FieldType::STRING_ARRAY => "literal-array",
AgnosticBackend::Indexable::FieldType::DATE => "date",
AgnosticBackend::Indexable::FieldType::DATE_ARRAY=> "date-array",
- 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 48.
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
Method initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(value, type, from: nil, **options)
if type == FieldType::STRUCT && from.nil?
raise "A nested type requires the specification of a target class using the `from` argument"
end
@value = value.respond_to?(:call) ? value : value.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 trigger_index_notification
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def trigger_index_notification
return unless respond_to? :_index_root_notifiers
_index_root_notifiers.each do |index_name, block|
obj = instance_eval &block
obj = [obj] unless obj.respond_to? :each
- 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 value_for_key
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def value_for_key(document, key)
keys = key.split('.')
key = keys.shift
if document.is_a?(Hash)
if document.has_key? 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def format_dates_in(document)
document.each do |k, v|
if v.is_a?(Time)
document[k] = v.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
elsif v.is_a?(Array) && v.all?{|e| e.is_a?(Time)}
- 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 40.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def date_format(document)
document.each do |k, v|
if v.is_a?(Time)
document[k] = v.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
elsif v.is_a?(Array) && v.all?{|e| e.is_a?(Time)}
- 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 40.
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
Method build
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build(**options)
query = create_query(self, **options)
query.children << build_where_expression if @criterion
query.children << build_select_expression if @projections
query.children << build_order_expression if @order_qualifiers
- 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 to_s
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def to_s
result = ''
result += "search?q=#{query_expression}" if query_expression
result += " filter=#{filter_query}" if filter_query
result += " return=#{return_expression}" if return_expression
- 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 ==
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def ==(other)
return true if self.__id__ == other.__id__
return false if other.nil?
return false unless other.is_a? AgnosticBackend::Queryable::TreeNode
- 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"