codeclimate/codeclimate

View on GitHub
lib/cc/config/checks_adapter.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Add empty line after guard clause.
Open

        return unless checks.present?
Severity: Minor
Found in lib/cc/config/checks_adapter.rb by rubocop

Enforces empty line after guard clause

Example:

# bad
def foo
  return if need_return?
  bar
end

# good
def foo
  return if need_return?

  bar
end

# good
def foo
  return if something?
  return if something_different?

  bar
end

# also good
def foo
  if something?
    do_something
    return if need_return?
  end
end

Convert if-elsif to case-when.
Open

        if engine["config"].is_a?(String)
          engine["config"] = {
            "file" => engine["config"],
            "checks" => checks,
          }
Severity: Minor
Found in lib/cc/config/checks_adapter.rb by rubocop

Identifies places where if-elsif constructions can be replaced with case-when.

Safety:

This cop is unsafe. case statements use === for equality, so if the original conditional used a different equality operator, the behavior may be different.

Example:

# bad
if status == :active
  perform_action
elsif status == :inactive || status == :hibernating
  check_timeout
else
  final_action
end

# good
case status
when :active
  perform_action
when :inactive, :hibernating
  check_timeout
else
  final_action
end

Use each_key instead of keys.each.
Open

        DefaultAdapter::ENGINES.keys.each do |name|
Severity: Minor
Found in lib/cc/config/checks_adapter.rb by rubocop

Checks for uses of each_key and each_value Hash methods.

NOTE: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

Safety:

This cop is unsafe because it cannot be guaranteed that the receiver is a Hash. The AllowedReceivers configuration can mitigate, but not fully resolve, this safety issue.

Example:

# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }

# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }

Example: AllowedReceivers: ['execute']

# good
execute(sql).keys.each { |v| p v }
execute(sql).values.each { |v| p v }

There are no issues that match your filters.

Category
Status