Assignment Branch Condition size for awesome_ripple_document_instance is too high. [19.1/15] Open
def awesome_ripple_document_instance(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
exclude_assoc = @options[:exclude_assoc] or @options[:exclude_associations]
- 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. [14/10] Open
def awesome_ripple_document_instance(object)
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
return awesome_object(object) if @options[:raw]
exclude_assoc = @options[:exclude_assoc] or @options[:exclude_associations]
- 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.
Line is too long. [102/80] Open
elsif object.is_a?(::Ripple::Properties) # Used to access property metadata on Ripple classes
- Exclude checks
Line is too long. [83/80] Open
#------------------------------------------------------------------------------
- Exclude checks
Line is too long. [131/80] Open
hash[assoc.name] = object.get_proxy(assoc) # Should always be array or Ripple::EmbeddedDocument for embedded associations
- Exclude checks
Use ||
instead of or
. Open
exclude_assoc = @options[:exclude_assoc] or @options[:exclude_associations]
- Read upRead up
- Exclude checks
This cop checks for uses of and
and or
, and suggests using &&
and
|| instead
. It can be configured to check only in conditions, or in
all contexts.
Example: EnforcedStyle: always (default)
# bad
foo.save and return
# bad
if foo and bar
end
# good
foo.save && return
# good
if foo && bar
end
Example: EnforcedStyle: conditionals
# bad
if foo and bar
end
# good
foo.save && return
# good
foo.save and return
# good
if foo && bar
end
Use each_with_object
instead of inject
. Open
data = object.attributes.inject(::ActiveSupport::OrderedHash.new) do |hash, (name, value)|
- Read upRead up
- Exclude checks
This cop looks for inject / reduce calls where the passed in object is returned at the end and so could be replaced by eachwithobject without the need to return the object at the end.
However, we can't replace with eachwithobject if the accumulator parameter is assigned to within the block.
Example:
# bad
[1, 2].inject({}) { |a, e| a[e] = e; a }
# good
[1, 2].each_with_object({}) { |e, a| a[e] = e }
Line is too long. [96/80] Open
data = object.attributes.inject(::ActiveSupport::OrderedHash.new) do |hash, (name, value)|
- Exclude checks
Favor unless
over if
for negative conditions. Open
return cast if !defined?(::Ripple)
- Read upRead up
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
Line is too long. [106/80] Open
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:properties)
- Exclude checks
Unused block argument - value
. If it's necessary, use _
or _value
as an argument name to indicate that it won't be used. Open
data = object.attributes.inject(::ActiveSupport::OrderedHash.new) do |hash, (name, value)|
- Read upRead up
- Exclude checks
This cop checks for unused block arguments.
Example:
# bad
do_something do |used, unused|
puts used
end
do_something do |bar|
puts :foo
end
define_method(:foo) do |bar|
puts :baz
end
Example:
#good
do_something do |used, _unused|
puts used
end
do_something do
puts :foo
end
define_method(:foo) do |_bar|
puts :baz
end
Missing top-level module documentation comment. Open
module Ripple
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end
Favor unless
over if
for negative conditions. Open
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
- Read upRead up
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
Line is too long. [95/80] Open
# NOTE: by default only instance attributes are shown. To format a Ripple document instance
- Exclude checks
Extra empty line detected at module body beginning. Open
def self.included(base)
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Use each_with_object
instead of inject
. Open
data = object.class.embedded_associations.inject(data) do |hash, assoc|
- Read upRead up
- Exclude checks
This cop looks for inject / reduce calls where the passed in object is returned at the end and so could be replaced by eachwithobject without the need to return the object at the end.
However, we can't replace with eachwithobject if the accumulator parameter is assigned to within the block.
Example:
# bad
[1, 2].inject({}) { |a, e| a[e] = e; a }
# good
[1, 2].each_with_object({}) { |e, a| a[e] = e }
Line is too long. [83/80] Open
#------------------------------------------------------------------------------
- Exclude checks
Line is too long. [124/80] Open
if object.is_a?(::Ripple::AttributeMethods) # Module used to access attributes across documents and embedded documents
- Exclude checks
Line is too long. [83/80] Open
#------------------------------------------------------------------------------
- Exclude checks
Line is too long. [95/80] Open
# as a regular object showing its instance variables and accessors use :raw => true option:
- Exclude checks
Line is too long. [81/80] Open
exclude_assoc = @options[:exclude_assoc] or @options[:exclude_associations]
- Exclude checks