brpoplpush/brpoplpush-redis_script

View on GitHub
bin/rake

Summary

Maintainability
Test Coverage

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

  if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
Severity: Minor
Found in bin/rake 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

Align the arguments of a method call if they span more than one line.
Open

  Pathname.new(__FILE__).realpath)
Severity: Minor
Found in bin/rake by rubocop

Here we check if the arguments on a multi-line method definition are aligned.

Example: EnforcedStyle: withfirstargument (default)

# good

foo :bar,
    :baz

foo(
  :bar,
  :baz
)

# bad

foo :bar,
  :baz

foo(
  :bar,
    :baz
)

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz

Use expand_path('bundle', __dir__) instead of expand_path('../bundle', __FILE__).
Open

bundle_binstub = File.expand_path("../bundle", __FILE__)
Severity: Minor
Found in bin/rake by rubocop

This cop checks for use of the File.expand_path arguments. Likewise, it also checks for the Pathname.new argument.

Contrastive bad case and good case are alternately shown in the following examples.

Example:

# bad
File.expand_path('..', __FILE__)

# good
File.expand_path(__dir__)

# bad
File.expand_path('../..', __FILE__)

# good
File.expand_path('..', __dir__)

# bad
File.expand_path('.', __FILE__)

# good
File.expand_path(__FILE__)

# bad
Pathname(__FILE__).parent.expand_path

# good
Pathname(__dir__).expand_path

# bad
Pathname.new(__FILE__).parent.expand_path

# good
Pathname.new(__dir__).expand_path

There are no issues that match your filters.

Category
Status