ServiceInnovationLab/RapuTure

View on GitHub
app/services/entities_fetch_service.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for fetch_all is too high. [20.59/15]
Open

  def self.fetch_all
    json_response = of_conn.get('entities').body
    json_response.keys.each do |name|
      entity_json = json_response.fetch(name, {})
      entity = Entity.find_or_initialize_by(name: name)

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

Use each_key instead of keys.each.
Open

    json_response.keys.each do |name|

This cop checks for uses of each_key and each_value Hash methods.

Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

Example:

# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }

# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }

Shadowing outer local variable - name.
Open

      entity_json.fetch('roles', []).each do |name, role_json|

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

There are no issues that match your filters.

Category
Status