Do not use ::
for method calls. Open
string.force_encoding(Encoding::default_external)
- Read upRead up
- Exclude checks
This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Example:
# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)
# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)
Line is too long. [91/80] Open
reply = CommandError.new(reply.message) if reply.is_a?(::Oxblood::Protocol::RError)
- Exclude checks
Do not use ::
for method calls. Open
if defined?(Encoding::default_external)
- Read upRead up
- Exclude checks
This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Example:
# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)
# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)
Missing top-level class documentation comment. Open
class Oxblood
- 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
Provide an exception class and message as arguments to raise
. Open
raise Redis::ProtocolError.new(e.message)
- Read upRead up
- Exclude checks
This cop checks the args passed to fail
and raise
. For exploded
style (default), it recommends passing the exception class and message
to raise
, rather than construct an instance of the error. It will
still allow passing just a message, or the construction of an error
with more than one argument.
The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.
Example: EnforcedStyle: exploded (default)
# bad
raise StandardError.new("message")
# good
raise StandardError, "message"
fail "message"
raise MyCustomError.new(arg1, arg2, arg3)
raise MyKwArgError.new(key1: val1, key2: val2)
Example: EnforcedStyle: compact
# bad
raise StandardError, "message"
raise RuntimeError, arg1, arg2, arg3
# good
raise StandardError.new("message")
raise MyCustomError.new(arg1, arg2, arg3)
fail "message"
Provide an exception class and message as arguments to raise
. Open
raise Redis::TimeoutError.new(e.message)
- Read upRead up
- Exclude checks
This cop checks the args passed to fail
and raise
. For exploded
style (default), it recommends passing the exception class and message
to raise
, rather than construct an instance of the error. It will
still allow passing just a message, or the construction of an error
with more than one argument.
The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.
Example: EnforcedStyle: exploded (default)
# bad
raise StandardError.new("message")
# good
raise StandardError, "message"
fail "message"
raise MyCustomError.new(arg1, arg2, arg3)
raise MyKwArgError.new(key1: val1, key2: val2)
Example: EnforcedStyle: compact
# bad
raise StandardError, "message"
raise RuntimeError, arg1, arg2, arg3
# good
raise StandardError.new("message")
raise MyCustomError.new(arg1, arg2, arg3)
fail "message"