File couch.rb
has 417 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "rack/client"
module Npolar
module Storage
Class Couch
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class Couch
# Delegate validation to model
#extend Forwardable # http://www.ruby-doc.org/stdlib-1.9.3/libdoc/forwardable/rdoc/Forwardable.html
#def_delegators :model, :valid?
Method post_many
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def post_many(data, params={})
if data !~ JSON_ARRAY_REGEX
raise ArgumentException, "Please provide data as JSON Array"
end
t0 = Time.now
Method post
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def post(data, params={})
#unless valid? data
# raise Exception
#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 post_many
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def post_many(data, params={})
if data !~ JSON_ARRAY_REGEX
raise ArgumentException, "Please provide data as JSON Array"
end
t0 = Time.now
- 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 initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(read, write = nil, config = {})
if read.respond_to? :key? and read.key? "read"
if write.nil? and read.key? "write"
write = read["write"]
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 valid?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def valid? data, context="POST"
@errors = []
# First, check JSON syntax
begin
- 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 valid?
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def valid? data, context="POST"
@errors = []
# First, check JSON syntax
begin
Method post
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def post(data, params={})
#unless valid? data
# raise Exception
#end
Method feed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def feed(params={})
response = couch.get(all_docs_uri(true))
if 200 == response.status
- 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 fetch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fetch(id,key=nil)
begin
status, headers, jsonstring = get(id)
- 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 put
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def put(id, data, params={})
if data.is_a? Hash
data = data.to_json
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"