Avoid using rescue
in its modifier form. Open
Date.parse(subnode_text('PublicationDate')) rescue nil
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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|
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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