rocketsofawesome/newgistics-ruby

View on GitHub
lib/newgistics/xml_marshaller.rb

Summary

Maintainability
A
0 mins
Test Coverage

Use each_value instead of values.each.
Open

      root.attributes.values.each do |attribute|
Severity: Minor
Found in lib/newgistics/xml_marshaller.rb by rubocop

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 }

Line is too long. [84/80]
Open

        object[attribute] = build_list(attribute_set.member_type.primitive, element)
Severity: Minor
Found in lib/newgistics/xml_marshaller.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

      if object.is_a?(Hash) || object.respond_to?(setter)
Severity: Minor
Found in lib/newgistics/xml_marshaller.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Use the return of the conditional for variable assignment and comparison.
Open

      if attribute_set.type.primitive == Array
        object[attribute] = build_list(attribute_set.member_type.primitive, element)
      else
        object[attribute] = build_object(attribute_set.type.primitive, element)
      end
Severity: Minor
Found in lib/newgistics/xml_marshaller.rb by rubocop

There are no issues that match your filters.

Category
Status