ManageIQ/manageiq

View on GitHub
app/models/manageiq/providers/inventory/persister.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
92%

Use filter_map instead.
Open

    collections_data = collections.map do |_, collection|
      next if collection.data.blank? &&
              collection.targeted_scope.primary_references.blank? &&
              collection.all_manager_uuids.nil? &&
              collection.skeletal_primary_index.index_data.blank?

#to_json requires an optional argument to be parsable via JSON.generate(obj).
Open

  def to_json
    JSON.dump(to_hash)
  end

Checks to make sure #to_json includes an optional argument. When overriding #to_json, callers may invoke JSON generation via JSON.generate(your_obj). Since JSON#generate allows for an optional argument, your method should too.

Example:

class Point
  attr_reader :x, :y

  # bad, incorrect arity
  def to_json
    JSON.generate([x, y])
  end

  # good, preserving args
  def to_json(*args)
    JSON.generate([x, y], *args)
  end

  # good, discarding args
  def to_json(*_args)
    JSON.generate([x, y])
  end
end

There are no issues that match your filters.

Category
Status