Showing 661 of 695 total issues
Missing top-level class documentation comment. Open
class HaveTag
- Read upRead up
- Create a ticketCreate a ticket
- 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
Non-local exit from iterator, without return value. next
, break
, Array#find
, Array#any?
, etc. is preferred. Open
return unless (@field = card.fetch(field_key))
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for non-local exits from iterators without a return value. It registers an offense under these conditions:
- No value is returned,
- the block is preceded by a method chain,
- the block has arguments,
- the method which receives the block is not
define_method
ordefine_singleton_method
, - the return is not contained in an inner scope, e.g. a lambda or a method definition.
Example:
class ItemApi
rescue_from ValidationError do |e| # non-iteration block with arg
return { message: 'validation error' } unless e.errors # allowed
error_array = e.errors.map do |error| # block with method chain
return if error.suppress? # warned
return "#{error.param}: invalid" unless error.message # allowed
"#{error.param}: #{error.message}"
end
{ message: 'validation error', errors: error_array }
end
def update_items
transaction do # block without arguments
return unless update_necessary? # allowed
find_each do |item| # block without method chain
return if item.stock == 0 # false-negative...
item.update!(foobar: true)
end
end
end
end
Avoid the use of the case equality operator ===
. Open
@size === @file.file.size
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for uses of the case equality operator(===).
Example:
# bad
Array === something
(1..100) === 7
/something/ === some_string
# good
something.is_a?(Array)
(1..100).include?(7)
some_string =~ /something/
Start context description with 'when', 'with', or 'without'. Open
context "Class" do
- Create a ticketCreate a ticket
- Exclude checks
Prefer have_received
for setting message expectations. Setup format
as a spy using allow
or instance_spy
. Open
expect(format).to receive(:render!).with("viewname", { structure: :crooked })
- Create a ticketCreate a ticket
- Exclude checks
Do not suppress exceptions. Open
rescue Card::Error
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for rescue blocks with no body.
Example:
# bad
def some_method
do_something
rescue
# do nothing
end
Example:
# bad
begin
do_something
rescue
# do nothing
end
Example:
# good
def some_method
do_something
rescue
handle_exception
end
Example:
# good
begin
do_something
rescue
handle_exception
end
The first argument to describe should be the class or module being tested. Open
RSpec.describe "Card::Director" do
- Create a ticketCreate a ticket
- Exclude checks
Prefer have_received
for setting message expectations. Setup store
as a spy using allow
or instance_spy
. Open
expect(store).to receive(:read).with("#{prefix}/foo")
- Create a ticketCreate a ticket
- Exclude checks
Missing top-level class documentation comment. Open
class CardSpecLoader
- Read upRead up
- Create a ticketCreate a ticket
- 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
include
is used at the top level. Use inside class
or module
. Open
include RSpecHtmlMatchers::SyntaxHighlighting
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that include
, extend
and prepend
exists at
the top level.
Using these at the top level affects the behavior of Object
.
There will not be using include
, extend
and prepend
at
the top level. Let's use it inside class
or module
.
Example:
# bad
include M
class C
end
# bad
extend M
class C
end
# bad
prepend M
class C
end
# good
class C
include M
end
# good
class C
extend M
end
# good
class C
prepend M
end
Missing top-level module documentation comment. Open
module ClassMethods
- Read upRead up
- Create a ticketCreate a ticket
- 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
Use let
instead of an instance variable. Open
trans = @current_trans && !reset ? @current_trans : __current_trans
- Create a ticketCreate a ticket
- Exclude checks
Prefer have_received
for setting message expectations. Setup card_double
as a spy using allow
or instance_spy
. Open
expect(card_double).not_to receive(:find_by_key_and_trash)
- Create a ticketCreate a ticket
- Exclude checks
Spec path should end with /codename*Codename*_spec.rb
. Open
RSpec.describe Card::Codename, "Codename" do
- Create a ticketCreate a ticket
- Exclude checks
Prefer have_received
for setting message expectations. Setup format
as a spy using allow
or instance_spy
. Open
expect(format).to receive(:render!).with("viewname", { skip_perms: true })
- Create a ticketCreate a ticket
- Exclude checks
Prefer have_received
for setting message expectations. Setup format
as a spy using allow
or instance_spy
. Open
expect(format).to receive(:render!).with("viewname", { optional: :show,
- Create a ticketCreate a ticket
- Exclude checks
Prefer have_received
for setting message expectations. Setup store
as a spy using allow
or instance_spy
. Open
expect(store).not_to receive(:write)
- Create a ticketCreate a ticket
- Exclude checks
Missing top-level module documentation comment. Open
module Transformers
- Read upRead up
- Create a ticketCreate a ticket
- 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
Name your test subject if you need to reference it explicitly. Open
expect(subject.s).to eq "Decko Bot"
- Create a ticketCreate a ticket
- Exclude checks
Missing top-level module documentation comment. Open
module Object
- Read upRead up
- Create a ticketCreate a ticket
- 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