decko-commons/decko

View on GitHub

Showing 666 of 699 total issues

Use let instead of an instance variable.
Open

      body = @mail.parts[0].body.raw_source

Start context description with 'when', 'with', or 'without'.
Open

    context "A+B+C" do
Severity: Minor
Found in cardname/spec/lib/cardname_spec.rb by rubocop

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
Severity: Minor
Found in mod/account/set/right/password.rb by rubocop

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

Use let instead of an instance variable.
Open

      expect(@account.salt).not_to eq("")

Use let instead of an instance variable.
Open

        expect(@format.render_raw).to eq("u1@user.com")

Use let instead of an instance variable.
Open

      raw_source = @mail.parts[0].body.raw_source

Use let instead of an instance variable.
Open

      expect(Card::Auth.current_id).to eq(@account.left_id)

Prefer annotated tokens (like %<foo>s</foo>) over unannotated tokens (like %s).
Open

      "%s/%s" % [file_dir, url_filename]

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

Name your test subject if you need to reference it explicitly.
Open

          expect(subject.file.url).to(

Name your test subject if you need to reference it explicitly.
Open

      expect(subject.image.size).to eq 6836

Name your test subject if you need to reference it explicitly.
Open

        expect(subject.image.original_filename).to eq "rails.gif"

Name your test subject if you need to reference it explicitly.
Open

      expect(subject.content).to eq ":#{subject.codename}/bootstrap.png"

Name your test subject if you need to reference it explicitly.
Open

          .to eq "/files/:#{subject.codename}/bootstrap-medium.png"

Do not stub your test subject.
Open

      allow(format).to receive(:view_setting).and_return %i[other modal]

Do not stub your test subject.
Open

      allow(format).to receive(:view_setting)

Empty example group detected.
Open

  context "when admin is following" do

Use let instead of an instance variable.
Open

      expect(@mail.parts[0].body.raw_source).to include(msg)

Use let instead of an instance variable.
Open

      @account.update! trigger: :reset_password
Severity
Category
Status
Source
Language