Showing 10 of 18 total issues
Method included
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
endpoint GeoCerts::API::ENDPOINT do
action :orders, :url => '/orders.xml' do
Method xml_node_to_hash
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def xml_node_to_hash(node)
# If we are at the root of the document, start the hash
if node.element?
if node.children?
result_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
Class Order
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Order < ApiObject
attr_accessor :approver_email,
:approver_confirmed_at,
:approver_notified_at,
Method included
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
endpoint GeoCerts::API::ENDPOINT do
action :query_fraud_score, :url => '/fraud_score.xml', :method => :post do
parameter 'fraud_score[ip]', :required => true, :as => :ip
Method included
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
endpoint GeoCerts::API::ENDPOINT do
action :events, :url => '/events.xml' do
Method included
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.class_eval do
endpoint GeoCerts::API::ENDPOINT do
action :certificates, :url => '/certificates.xml' do
Method create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
parameters = {}
parameters[:approver_email] = GeoCerts.escape(self.approver_email)
parameters[:years] = GeoCerts.escape(self.years)
parameters[:licenses] = GeoCerts.escape(self.licenses)
- 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 xml_node_to_hash
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def xml_node_to_hash(node)
# If we are at the root of the document, start the hash
if node.element?
if node.children?
result_hash = {}
Avoid deeply nested control flow statements. Open
if result_hash[child.name].is_a?(Object::Array)
result_hash[child.name] << result
else
result_hash[child.name] = [result_hash[child.name]] << result
end
Method validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate
parameters = {}
parameters[:years] = self.years
parameters[:licenses] = self.licenses
parameters[:sans] = GeoCerts.escape(self.sans) if self.sans
- 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"