Showing 19 of 19 total issues
Method add_extra_customizations
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def add_extra_customizations
# We can't know everything from the wsdl, like which fields are
# usable in queries. This function does some final customizations
# based on the existing Zuora documentation.
# Also, it's possible classes customized here weren't defined
- 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 Relation
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Relation
attr_accessor :selected_field_names, :filters, :order_attribute, :order_direction
attr_reader :zobject_class
Method add_extra_customizations
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_extra_customizations
# We can't know everything from the wsdl, like which fields are
# usable in queries. This function does some final customizations
# based on the existing Zuora documentation.
# Also, it's possible classes customized here weren't defined
Method has_many
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def has_many(items, options={})
class_name = options[:class_name] || nested_class_name(items.to_s.singularize.camelize)
foreign_key = options[:foreign_key] || :"#{zuora_object_name.underscore}_id"
conditions = options[:conditions]
# :order => :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 generate_classes
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_classes
# Defines the classes based on the wsdl document.
# Assumes the following namespaces in the wsdl.
# xmlns="http://schemas.xmlsoap.org/wsdl/"
Method belongs_to
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def belongs_to(item, options={})
class_name = options[:class_name] || nested_class_name(item.to_s.camelize)
foreign_key = options[:foreign_key] || :"#{item}_id"
# Add the field if it doesn't already exist.
field foreign_key, :string unless field? foreign_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 belongs_to
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def belongs_to(item, options={})
class_name = options[:class_name] || nested_class_name(item.to_s.camelize)
foreign_key = options[:foreign_key] || :"#{item}_id"
# Add the field if it doesn't already exist.
field foreign_key, :string unless field? foreign_key
Method add_obvious_associations
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def add_obvious_associations
# When a zuora class has a field called InvoiceId, it's a safe
# assuption that it references the an Invoice.
# Build those associations automatically.
@classes.each do |zuora_class|
- 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 process_save
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def process_save(zobjects, action)
unless [:create, :update].include? action
raise "Invalid action type for saving. Must be create or update."
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 generate_classes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def generate_classes
# Defines the classes based on the wsdl document.
# Assumes the following namespaces in the wsdl.
# xmlns="http://schemas.xmlsoap.org/wsdl/"
- 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 process_save
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_save(zobjects, action)
unless [:create, :update].include? action
raise "Invalid action type for saving. Must be create or update."
end
Method where_statement
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def where_statement
return '' if @filters.empty?
tokens = []
@filters.each do |logical_operator, conditions|
if conditions.is_a?(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 query
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def query(&block)
# Keep querying until all pages are retrieved.
# Throws an exception for an invalid query.
response = zobject_class.connection.request(:query){ |soap| soap.body = { :query_string => to_zql } }
query_response = response[:query_response]
- 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 escape_filter_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def escape_filter_value(value)
if value.nil?
"null"
elsif value.is_a?(String)
"'#{value.gsub("'","\\\\'")}'"
- 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 sort_records!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sort_records!(records)
return records unless order_attribute.present?
records.sort! do |a, b|
if a.nil?
-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 create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create
return false unless new_record? && valid?
result = self.class.connection.request(:create) do |soap|
soap.body do |xml|
build_xml(xml, soap,
- 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 3 locations. Consider refactoring. Open
self.result = self.class.connection.request(:amend) do |soap|
soap.body do |xml|
build_xml(xml, soap,
:namespace => soap.namespace,
:element_name => :requests,
- 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 28.
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 3 locations. Consider refactoring. Open
self.result = self.class.connection.request(:generate) do |soap|
soap.body do |xml|
build_xml(xml, soap,
:namespace => soap.namespace,
:element_name => :zObjects,
- 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 28.
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 3 locations. Consider refactoring. Open
self.result = self.class.connection.request(:subscribe) do |soap|
soap.body do |xml|
build_xml(xml, soap,
:namespace => soap.namespace,
:element_name => :subscribes,
- 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 28.
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