codeclimate/codeclimate

View on GitHub
lib/cc/cli/runner.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
90%

Use e instead of ex.
Open

      rescue => ex
Severity: Minor
Found in lib/cc/cli/runner.rb by rubocop

Makes sure that rescued exceptions variables are named as expected.

The PreferredName config option takes a String. It represents the required name of the variable. Its default is e.

NOTE: This cop does not consider nested rescues because it cannot guarantee that the variable from the outer rescue is not used within the inner rescue (in which case, changing the inner variable would shadow the outer variable).

Example: PreferredName: e (default)

# bad
begin
  # do something
rescue MyException => exception
  # do something
end

# good
begin
  # do something
rescue MyException => e
  # do something
end

# good
begin
  # do something
rescue MyException => _e
  # do something
end

Example: PreferredName: exception

# bad
begin
  # do something
rescue MyException => e
  # do something
end

# good
begin
  # do something
rescue MyException => exception
  # do something
end

# good
begin
  # do something
rescue MyException => _exception
  # do something
end

Avoid rescuing without specifying an error class.
Open

      rescue => ex
Severity: Minor
Found in lib/cc/cli/runner.rb by rubocop

Checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

Example: EnforcedStyle: implicit

# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.

# bad
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Example: EnforcedStyle: explicit (default)

# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.

# bad
begin
  foo
rescue
  bar
end

# good
begin
  foo
rescue StandardError
  bar
end

# good
begin
  foo
rescue OtherError
  bar
end

# good
begin
  foo
rescue StandardError, SecurityError
  bar
end

Prefer ary[n..] over ary[n..-1].
Open

        Array(@args[1..-1])
Severity: Minor
Found in lib/cc/cli/runner.rb by rubocop

Checks that arrays are sliced with endless ranges instead of ary[start..-1] on Ruby 2.6+.

Safety:

This cop is unsafe because x..-1 and x.. are only guaranteed to be equivalent for Array#[], and the cop cannot determine what class the receiver is.

For example: ruby sum = proc { |ary| ary.sum } sum[-3..-1] # => -6 sum[-3..] # Hangs forever

Example:

# bad
items[1..-1]

# good
items[1..]

There are no issues that match your filters.

Category
Status