awesome-print/awesome_print

View on GitHub
lib/awesome_print/ext/ripple.rb

Summary

Maintainability
A
0 mins
Test Coverage

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]

Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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]

Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Line is too long. [83/80]
Open

    #------------------------------------------------------------------------------
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Line is too long. [131/80]
Open

          hash[assoc.name] = object.get_proxy(assoc) # Should always be array or Ripple::EmbeddedDocument for embedded associations
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Use || instead of or.
Open

      exclude_assoc = @options[:exclude_assoc] or @options[:exclude_associations]
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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)|
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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)|
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Favor unless over if for negative conditions.
Open

      return cast if !defined?(::Ripple)
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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)
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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)|
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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)
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Extra empty line detected at module body beginning.
Open


    def self.included(base)
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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|
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

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

    #------------------------------------------------------------------------------
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Line is too long. [124/80]
Open

      if object.is_a?(::Ripple::AttributeMethods) # Module used to access attributes across documents and embedded documents
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Line is too long. [83/80]
Open

    #------------------------------------------------------------------------------
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Line is too long. [95/80]
Open

    # as a regular object showing its instance variables and accessors use :raw => true option:
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

Line is too long. [81/80]
Open

      exclude_assoc = @options[:exclude_assoc] or @options[:exclude_associations]
Severity: Minor
Found in lib/awesome_print/ext/ripple.rb by rubocop

There are no issues that match your filters.

Category
Status