Showing 666 of 699 total issues
Use let
instead of an instance variable. Open
body = @mail.parts[0].body.raw_source
- Create a ticketCreate a ticket
- Exclude checks
Start context description with 'when', 'with', or 'without'. Open
context "A+B+C" do
- Create a ticketCreate a ticket
- Exclude checks
Use safe navigation (&.
) instead of checking if an object exists before calling the method. Open
return "on" if @parent && @parent.card.name == "*signin+*account" # HACK
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop transforms usages of a method call safeguarded by a non nil
check for the variable whose method is being called to
safe navigation (&.
).
Configuration option: ConvertCodeThatCanStartToReturnNil
The default for this is false
. When configured to true
, this will
check for code in the format !foo.nil? && foo.bar
. As it is written,
the return of this code is limited to false
and whatever the return
of the method is. If this is converted to safe navigation,
foo&.bar
can start returning nil
as well as what the method
returns.
Example:
# bad
foo.bar if foo
foo.bar(param1, param2) if foo
foo.bar { |e| e.something } if foo
foo.bar(param) { |e| e.something } if foo
foo.bar if !foo.nil?
foo.bar unless !foo
foo.bar unless foo.nil?
foo && foo.bar
foo && foo.bar(param1, param2)
foo && foo.bar { |e| e.something }
foo && foo.bar(param) { |e| e.something }
# good
foo&.bar
foo&.bar(param1, param2)
foo&.bar { |e| e.something }
foo&.bar(param) { |e| e.something }
foo.nil? || foo.bar
!foo || foo.bar
# Methods that `nil` will `respond_to?` should not be converted to
# use safe navigation
foo.to_i if foo
Start context description with 'when', 'with', or 'without'. Open
context "signup (without approval)" do
- Create a ticketCreate a ticket
- Exclude checks
Use let
instead of an instance variable. Open
expect(@account.salt).not_to eq("")
- Create a ticketCreate a ticket
- Exclude checks
Use let
instead of an instance variable. Open
expect(@format.render_raw).to eq("u1@user.com")
- Create a ticketCreate a ticket
- Exclude checks
Use let
instead of an instance variable. Open
raw_source = @mail.parts[0].body.raw_source
- Create a ticketCreate a ticket
- Exclude checks
Use let
instead of an instance variable. Open
expect(Card::Auth.current_id).to eq(@account.left_id)
- Create a ticketCreate a ticket
- Exclude checks
Prefer annotated tokens (like %<foo>s</foo>
) over unannotated tokens (like %s
). Open
"%s/%s" % [file_dir, url_filename]
- Read upRead up
- Create a ticketCreate a ticket
- 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>
Start context description with 'when', 'with', or 'without'. Open
context "storage type:" do
- Create a ticketCreate a ticket
- Exclude checks
Name your test subject if you need to reference it explicitly. Open
expect(subject.file.url).to(
- Create a ticketCreate a ticket
- Exclude checks
Name your test subject if you need to reference it explicitly. Open
expect(subject.image.size).to eq 6836
- Create a ticketCreate a ticket
- Exclude checks
Name your test subject if you need to reference it explicitly. Open
expect(subject.image.original_filename).to eq "rails.gif"
- Create a ticketCreate a ticket
- Exclude checks
Name your test subject if you need to reference it explicitly. Open
expect(subject.content).to eq ":#{subject.codename}/bootstrap.png"
- Create a ticketCreate a ticket
- Exclude checks
Name your test subject if you need to reference it explicitly. Open
.to eq "/files/:#{subject.codename}/bootstrap-medium.png"
- Create a ticketCreate a ticket
- Exclude checks
Do not stub your test subject. Open
allow(format).to receive(:view_setting).and_return %i[other modal]
- Create a ticketCreate a ticket
- Exclude checks
Do not stub your test subject. Open
allow(format).to receive(:view_setting)
- Create a ticketCreate a ticket
- Exclude checks
Empty example group detected. Open
context "when admin is following" do
- Create a ticketCreate a ticket
- Exclude checks
Use let
instead of an instance variable. Open
expect(@mail.parts[0].body.raw_source).to include(msg)
- Create a ticketCreate a ticket
- Exclude checks
Use let
instead of an instance variable. Open
@account.update! trigger: :reset_password
- Create a ticketCreate a ticket
- Exclude checks