decko-commons/decko

View on GitHub

Showing 661 of 695 total issues

Use match? instead of =~ when MatchData is not used.
Open

      self =~ /^#{Regexp.escape joint}/ ? self : (joint + self)
Severity: Minor
Found in cardname/lib/cardname/manipulate.rb by rubocop

In Ruby 2.4, String#match?, Regexp#match? and Symbol#match? have been added. The methods are faster than match. Because the methods avoid creating a MatchData object or saving backref. So, when MatchData is not used, use match? instead of match.

Example:

# bad
def foo
  if x =~ /re/
    do_something
  end
end

# bad
def foo
  if x.match(/re/)
    do_something
  end
end

# bad
def foo
  if /re/ === x
    do_something
  end
end

# good
def foo
  if x.match?(/re/)
    do_something
  end
end

# good
def foo
  if x =~ /re/
    do_something(Regexp.last_match)
  end
end

# good
def foo
  if x.match(/re/)
    do_something($~)
  end
end

# good
def foo
  if /re/ === x
    do_something($~)
  end
end

Method Cardname#key is defined at both cardname/lib/cardname.rb:42 and cardname/lib/cardname.rb:74.
Open

  def key
Severity: Minor
Found in cardname/lib/cardname.rb by rubocop

This cop checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def duplicated
  1
end

def duplicated
  2
end

Example:

# bad

def duplicated
  1
end

alias duplicated other_duplicated

Example:

# good

def duplicated
  1
end

def other_duplicated
  2
end

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

Use let instead of an instance variable.
Open

      expect(@account.email).to eq("wolf@decko.org")

Use let instead of an instance variable.
Open

      expect(@card.errors[:signin].first).to match(/Wrong password/)

Use let instead of an instance variable.
Open

      @format = @card.format

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

    context "valid user" do

Use let instead of an instance variable.
Open

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

Use let instead of an instance variable.
Open

      assert_equal @account, authenticated

Use let instead of an instance variable.
Open

      Card::Env.params[:token] = Card::Auth::Token.encode @account.left_id, extra_payload

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

            .to eq "~#{subject.id}/#{subject.last_action_id}.txt"

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

          subject

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

      expect(subject.image.url)

Freeze mutable objects assigned to constants.
Open

RECAPTCHA_ERROR_CODES = {  # LOCALIZE
  "missing-input-secret" =>    "secret parameter is missing",
  "invalid-input-secret" =>    "secret parameter is invalid or malformed",
  "missing-input-response" =>    "response parameter is missing",
  "invalid-input-response" =>    "response parameter is invalid or malformed",
Severity: Minor
Found in mod/recaptcha/set/all/recaptcha.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Script file start_follow_link.rb doesn't have execute permission.
Open

#! no set module

Missing top-level class documentation comment.
Open

class FollowLink

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

Missing top-level module documentation comment.
Open

module SelectedAction
Severity: Minor
Found in mod/carrierwave/set/type/file.rb by rubocop

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

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

  context "creating" do

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

      context "unprotected" do

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

      expect(subject.original_filename).to eq "file2.txt"
Severity
Category
Status
Source
Language