Showing 387 of 387 total issues
Class has too many lines. [118/100] Open
class Inspector
attr_accessor :options, :indentator
AP = :__awesome_print__
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Class has too many lines. [105/100] Open
class ArrayFormatter < BaseFormatter
attr_reader :array, :inspector, :options
def initialize(array, inspector)
@array = array
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [41/10] 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.
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for format is too high. [44.02/15] 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
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for format is too high. [40.91/15] 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
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [33/10] 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
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [33/10] 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
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for colorize is too high. [33.6/15] Open
def colorize(str, type)
str = CGI.escapeHTML(str) if options[:html]
if options[:plain] || !options[:color][type] || !inspector.colorize?
str
#
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [23/10] Open
def method_tuple(method)
if method.respond_to?(:parameters) # Ruby 1.9.2+
# 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)|
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for awesome_active_model_error is too high. [26.98/15] Open
def awesome_active_model_error(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
object_dump = object.marshal_dump.first
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for awesome_mongo_mapper_class is too high. [26.78/15] Open
def awesome_mongo_mapper_class(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:keys)
data = object.keys.sort.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
hash[c.first] = (c.last.type || 'undefined').to_s.underscore.intern
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for limited is too high. [26.55/15] Open
def limited(data, width, is_hash = false)
limit = get_limit_size
if data.length <= limit
data
else
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for method_tuple is too high. [26.32/15] Open
def method_tuple(method)
if method.respond_to?(:parameters) # Ruby 1.9.2+
# 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)|
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for awesome_mongo_mapper_instance is too high. [25.24/15] Open
def awesome_mongo_mapper_instance(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
data = object.keys.keys.sort_by { |k| k }.inject(::ActiveSupport::OrderedHash.new) do |hash, name|
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
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 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 has too many lines. [18/10] Open
def awesome_mongo_mapper_instance(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
data = object.keys.keys.sort_by { |k| k }.inject(::ActiveSupport::OrderedHash.new) do |hash, name|
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for awesome_mongoid_class is too high. [23.54/15] Open
def awesome_mongoid_class(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:fields)
data = object.fields.sort_by { |key| key }.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
hash[c[1].name.to_sym] = (c[1].type || 'undefined').to_s.underscore.intern
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for awesome_active_record_instance is too high. [22.05/15] Open
def awesome_active_record_instance(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
data = if object.class.column_names != object.attributes.keys
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for awesome_active_record_class is too high. [22.91/15] Open
def awesome_active_record_class(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:columns) || object.to_s == 'ActiveRecord::Base'
return awesome_class(object) if object.respond_to?(:abstract_class?) && object.abstract_class?
data = object.columns.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [16/10] Open
def awesome_active_model_error(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
object_dump = object.marshal_dump.first
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.