Showing 22 of 36 total issues
Method format
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def format
vars = variables.map do |var|
property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
accessor = if object.respond_to?(:"#{property}=")
object.respond_to?(property) ? :accessor : :writer
- 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 format
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def format
vars = variables.map do |var|
property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
accessor = if struct.respond_to?(:"#{property}=")
struct.respond_to?(property) ? :accessor : :writer
- 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 awesome_active_record_instance
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def awesome_active_record_instance(object)
return object.inspect unless defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
data = if object.class.column_names == object.attributes.keys
- 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 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(options = {})
@options = {
indent: 4, # Number of spaces for indenting.
index: true, # Display array indices.
html: false, # Use ANSI color codes rather than HTML.
Method format
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def format
vars = variables.map do |var|
property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
accessor = if object.respond_to?(:"#{property}=")
object.respond_to?(property) ? :accessor : :writer
Method format
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def format
vars = variables.map do |var|
property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
accessor = if struct.respond_to?(:"#{property}=")
struct.respond_to?(property) ? :accessor : :writer
Method awesome_mongoid_document
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def awesome_mongoid_document(object)
return object.inspect unless defined?(::ActiveSupport::OrderedHash)
aliases = object.aliased_fields.invert
data = (object.attributes || {}).sort.each_with_object(::ActiveSupport::OrderedHash.new) do |c, 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 mode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def mode
r = ['-'] * 6
r[0] = 'd' if @stat.directory?
r[1] = 'a' unless (@attrs & FILE_ATTRIBUTE_ARCHIVE).zero?
r[2] = 'r' unless (@attrs & FILE_ATTRIBUTE_READONLY).zero?
- 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 awesome_mongo_mapper_instance
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def awesome_mongo_mapper_instance(object)
return object.inspect unless defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
data = object.keys.keys.sort.each_with_object(::ActiveSupport::OrderedHash.new) do |name, 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 cast_with_mongoid
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def cast_with_mongoid(object, type)
cast = cast_without_mongoid(object, type)
if defined?(::Mongoid::Document)
if object.is_a?(Class) && object.ancestors.include?(::Mongoid::Document)
cast = :mongoid_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 awesome_mongoid_class
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def awesome_mongoid_class(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:fields)
aliases = object.aliased_fields.invert
data = object.fields.sort.each_with_object(::ActiveSupport::OrderedHash.new) do |c, 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 cast_with_active_record
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def cast_with_active_record(object, type)
cast = cast_without_active_record(object, type)
return cast unless defined?(::ActiveRecord::Base)
if object.is_a?(::ActiveRecord::Base)
- 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 cast_with_mongo_mapper
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def cast_with_mongo_mapper(object, type)
apply_default_mongo_mapper_options
cast = cast_without_mongo_mapper(object, type)
if defined?(::MongoMapper::Document)
- 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 call
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.call
return if @load_attemps >= EXT_LOAD_ATTEMPT_LIMIT
require_relative 'ext/mongo_mapper' if defined?(MongoMapper)
require_relative 'ext/mongoid' if defined?(Mongoid)
- 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 printable_hash
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def printable_hash
data = printable_keys
width = left_width(data)
data.map! do |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 convert_to_hash
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def convert_to_hash(object)
return nil unless object.respond_to?(:to_hash)
return nil if object.method(:to_hash).arity != 0
- 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 method_tuple
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def method_tuple(method)
# See http://readruby.chengguangnan.com/methods#method-objects-parameters
# (mirror: http://archive.is/XguCA#selection-3381.1-3381.11)
args = method.parameters.inject([]) do |arr, (type, name)|
name ||= (type == :block ? 'block' : "arg#{arr.size + 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 cast_with_active_support
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cast_with_active_support(object, type)
cast = cast_without_active_support(object, type)
if defined?(::ActiveSupport) && defined?(::HashWithIndifferentAccess)
if (defined?(::ActiveSupport::TimeWithZone) && object.is_a?(::ActiveSupport::TimeWithZone)) || object.is_a?(::Date)
cast = :active_support_time
- 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 awesome_ripple_document_instance
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def awesome_ripple_document_instance(object)
return object.inspect unless defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
(exclude_assoc = @options[:exclude_assoc]) || @options[:exclude_associations]
- 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 colorize?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def colorize?
AmazingPrint.force_colors ||= false
AmazingPrint.force_colors || (
if defined? @colorize_stdout
@colorize_stdout
- 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"