supherman/dustbag

View on GitHub
lib/dustbag/item_attributes.rb

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using rescue in its modifier form.
Open

      Date.parse(subnode_text('PublicationDate')) rescue nil
Severity: Minor
Found in lib/dustbag/item_attributes.rb by rubocop

This cop checks for uses of rescue in its modifier form.

Example:

# bad
some_method rescue handle_error

# good
begin
  some_method
rescue
  handle_error
end

Pass &:text as an argument to map instead of a block.
Open

      list && list.locate('UPCListElement').map do |element|
        element.text
      end
Severity: Minor
Found in lib/dustbag/item_attributes.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Missing top-level class documentation comment.
Open

  class ItemAttributes
Severity: Minor
Found in lib/dustbag/item_attributes.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

Pass &:text as an argument to map instead of a block.
Open

      list && list.locate('EANListElement').map do |element|
        element.text
      end
Severity: Minor
Found in lib/dustbag/item_attributes.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Use each_with_object instead of inject.
Open

      repeated_subnodes('Creator').inject({}) do |acc, val|
Severity: Minor
Found in lib/dustbag/item_attributes.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 }

Avoid using rescue in its modifier form.
Open

      Date.parse(subnode_text('ReleaseDate')) rescue nil
Severity: Minor
Found in lib/dustbag/item_attributes.rb by rubocop

This cop checks for uses of rescue in its modifier form.

Example:

# bad
some_method rescue handle_error

# good
begin
  some_method
rescue
  handle_error
end

There are no issues that match your filters.

Category
Status