Showing 18 of 24 total issues
Class Base
has 61 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
# ParseResource::Base provides an easy way to use Ruby to interace with a Parse.com backend
# Usage:
# class Post < ParseResource::Base
# fields :title, :author, :body
File base.rb
has 509 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "rubygems"
require "bundler/setup"
require "active_model"
require "erb"
require "rest-client"
Method relations_for_saving
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def relations_for_saving(put_attrs)
all_add_item_queries = {}
all_remove_item_queries = {}
@unsaved_attributes.each_pair do |key, value|
next if !value.is_a? Array
- 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 batch_save
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def self.batch_save(save_objects, slice_size = 20, method = nil)
return true if save_objects.blank?
load_settings
base_uri = "https://api.parse.com/1/batch"
- 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 turn_relation_hash_into_object
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def turn_relation_hash_into_object(hash)
return nil if hash == nil or hash["className"] == "_User"
relation_object = hash["className"].to_s.constantize.new if hash["className"] != "_User"
hash.each do |key, value|
class_name_in_a_hash = false
- 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 Query
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Query
def initialize(klass)
@klass = klass
end
Method get_attribute
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_attribute(k)
attrs = @unsaved_attributes[k.to_s] ? @unsaved_attributes : @attributes
case attrs[k]
when Hash
klass_name = attrs[k]["className"]
- 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 relations_for_saving
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def relations_for_saving(put_attrs)
all_add_item_queries = {}
all_remove_item_queries = {}
@unsaved_attributes.each_pair do |key, value|
next if !value.is_a? Array
Method get_attribute
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_attribute(k)
attrs = @unsaved_attributes[k.to_s] ? @unsaved_attributes : @attributes
case attrs[k]
when Hash
klass_name = attrs[k]["className"]
Method initialize
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(code, msg="")
@msg = msg
@code = code
case code.to_s
when "111"
Method batch_save
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.batch_save(save_objects, slice_size = 20, method = nil)
return true if save_objects.blank?
load_settings
base_uri = "https://api.parse.com/1/batch"
Method execute
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def execute
if @klass.has_many_relations
relations = @klass.has_many_relations.map { |relation| relation.to_s }
include_object(relations)
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 turn_relation_hash_into_object
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def turn_relation_hash_into_object(hash)
return nil if hash == nil or hash["className"] == "_User"
relation_object = hash["className"].to_s.constantize.new if hash["className"] != "_User"
hash.each do |key, value|
class_name_in_a_hash = false
Method get_relation_objects
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_relation_objects(objects)
if @klass.has_many_relations
objects.each do |item|
@klass.has_many_relations.each do |relation|
item.attributes[relation.to_s] = [] if !item.attributes.has_key?(relation.to_s)
- 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 save
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def save
if valid?
run_callbacks :save do
if new?
create
- 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 exists?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exists?(query)
each do |item|
conditions_met = true
item.attributes.each do |key, value|
conditions_met = false if query.has_key?(key) and query[key] != 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 post_result
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def post_result(resp, req, res, &block)
if resp.code.to_s == "200" || resp.code.to_s == "201"
puts "request: #{req.inspect}"
merge_attributes(JSON.parse(resp))
- 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 upload
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.upload(file_instance, filename, options={})
load_settings
base_uri = "https://api.parse.com/1/files"
- 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"