Showing 368 of 368 total issues
Unnecessary utf-8 encoding comment. Open
# -*- encoding : utf-8 -*-
- Exclude checks
Add an empty line after magic comments. Open
module MotionSpec
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
Avoid rescuing the Exception
class. Perhaps you meant to rescue StandardError
? Open
rescue Exception => e
@rescued_exception = e
exception_matches(e)
- Read upRead up
- Exclude checks
This cop checks for rescue blocks targeting the Exception class.
Example:
# bad
begin
do_something
rescue Exception
handle_exception
end
Example:
# good
begin
do_something
rescue ArgumentError
handle_exception
end
Replace class var @@entered with a class instance var. Open
@@entered = false
- Read upRead up
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.
Missing top-level class documentation comment. Open
class RaiseError
- 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
Replace class var @@started with a class instance var. Open
@@started = nil
- Read upRead up
- Exclude checks
This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.
Add an empty line after magic comments. Open
module MotionSpec
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
Add an empty line after magic comments. Open
module MotionSpec
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
Unnecessary utf-8 encoding comment. Open
# -*- encoding : utf-8 -*-
- Exclude checks
Provide an exception class and message as arguments to fail
. Open
fail FailedExpectation.new(
FailMessageRenderer.message_for_be_true(negated, subject)
)
- 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"
Always use raise
to signal exceptions. Open
fail FailedExpectation.new(
- Read upRead up
- Exclude checks
This cop checks for uses of fail
and raise
.
Example: EnforcedStyle: only_raise (default)
# The `only_raise` style enforces the sole use of `raise`.
# bad
begin
fail
rescue Exception
# handle it
end
def watch_out
fail
rescue Exception
# handle it
end
Kernel.fail
# good
begin
raise
rescue Exception
# handle it
end
def watch_out
raise
rescue Exception
# handle it
end
Kernel.raise
Example: EnforcedStyle: only_fail
# The `only_fail` style enforces the sole use of `fail`.
# bad
begin
raise
rescue Exception
# handle it
end
def watch_out
raise
rescue Exception
# handle it
end
Kernel.raise
# good
begin
fail
rescue Exception
# handle it
end
def watch_out
fail
rescue Exception
# handle it
end
Kernel.fail
Example: EnforcedStyle: semantic
# The `semantic` style enforces the use of `fail` to signal an
# exception, then will use `raise` to trigger an offense after
# it has been rescued.
# bad
begin
raise
rescue Exception
# handle it
end
def watch_out
# Error thrown
rescue Exception
fail
end
Kernel.fail
Kernel.raise
# good
begin
fail
rescue Exception
# handle it
end
def watch_out
fail
rescue Exception
raise 'Preferably with descriptive message'
end
explicit_receiver.fail
explicit_receiver.raise
Add an empty line after magic comments. Open
module MotionSpec
- Read upRead up
- Exclude checks
Checks for a newline after the final magic comment.
Example:
# good
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
# Some code
end
Prefer annotated tokens (like %<foo>s</foo>
) over unannotated tokens (like %s
). Open
puts 'not ok %d - %s: %s' %
- Read upRead up
- Exclude checks
Use a consistent style for named format string tokens.
Note:
unannotated
style cop only works for strings
which are passed as arguments to those methods:
sprintf
, format
, %
.
The reason is that unannotated format is very similar
to encoded URLs or Date/Time formatting strings.
Example: EnforcedStyle: annotated (default)
# bad
format('%{greeting}', greeting: 'Hello')
format('%s', 'Hello')
# good
format('%<greeting>s', greeting: 'Hello')</greeting>
Example: EnforcedStyle: template
# bad
format('%<greeting>s', greeting: 'Hello')
format('%s', 'Hello')
# good
format('%{greeting}', greeting: 'Hello')</greeting>
Example: EnforcedStyle: unannotated
# bad
format('%<greeting>s', greeting: 'Hello')
format('%{greeting}', 'Hello')
# good
format('%s', 'Hello')</greeting>
Provide an exception class and message as arguments to fail
. Open
fail FailedExpectation.new(
FailMessageRenderer.message_for_include(negated, subject, @values)
)
- 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"
Unnecessary utf-8 encoding comment. Open
# -*- encoding : utf-8 -*-
- Exclude checks
Missing top-level class documentation comment. Open
class BeA
- 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
Line is too long. [138/120] Open
puts "##teamcity[testStarted timestamp = '#{java_time}' captureStandardOutput = 'true' name = '#{escape_message(description)}']\n\n"
- Exclude checks
Unnecessary utf-8 encoding comment. Open
# -*- encoding : utf-8 -*-
- Exclude checks
Provide an exception class and message as arguments to fail
. Open
fail InvalidMatcher.new(INVALID_MATCH_ERROR) unless @center_value
- 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"
Line is too long. [147/120] Open
puts "##teamcity[testFailed timestamp = '#{java_time}' message = '#{escape_message(error)}' name = '#{escape_message(@@description)}']\n\n"
- Exclude checks